相关疑难解决方法(0)

将Listview项转换为单个位图图像

参考此主题:Android获取所有ListView项目的屏幕截图

我想做类似的事情,但我有自定义适配器,它抛出我NullPointerException错误在此代码:

childView.measure(MeasureSpec.makeMeasureSpec(_listView.getWidth(),    MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
Run Code Online (Sandbox Code Playgroud)

我的定制适配器:

public class InvoiceListAdapter extends BaseAdapter {

  ArrayList<Object> _itemList;
  public Activity _context;
  public LayoutInflater _inflater;
  BarCodeGenerator Generator = new BarCodeGenerator();


  public InvoiceListAdapter(Activity context,ArrayList<Object> itemList)
  {
      super();
      this._context=context;
      this._itemList=itemList;
      this._inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

  }
@Override
public int getCount() {
    // TODO Auto-generated method stub
    return _itemList.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return _itemList.get(position);
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;
}

public static class …
Run Code Online (Sandbox Code Playgroud)

android listview bitmap

9
推荐指数
2
解决办法
3699
查看次数

以全长的方式截取RecyclerView的屏幕截图

我想获得活动的"整页"截图.该视图包含一个包含许多项目的RecyclerView.

我可以使用此功能截取当前视图的屏幕截图:

public Bitmap getScreenBitmap() {
    View v= findViewById(R.id.container).getRootView();
    v.setDrawingCacheEnabled(true);
    v.buildDrawingCache(true);
    Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
    v.setDrawingCacheEnabled(false); // clear drawing cache
    return b;
}
Run Code Online (Sandbox Code Playgroud)

但它只包含我可以正常查看的项目(如预期的那样).

当我拍摄截图时,有什么方法可以让RecyclerView神奇地显示全长(一次显示所有项目)吗?

如果没有,我该如何处理这个问题?

java android

8
推荐指数
3
解决办法
5601
查看次数

创建完整长度的RecyclerView PDF

我想创建活动的“整页” PDF。该视图包含一个RecyclerView,其中包含许多项。

我可以使用Recyclerview的完整尺寸,但是仅从当前视图绘制文件。这是我的代码:

    public void tela (){ // create a new document
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)

    {
        PdfDocument document = new PdfDocument();

        getScreenshotFromRecyclerView(mRecyclerView);
        content = mRecyclerView;
        content.setBackgroundColor(Color.parseColor("#303030"));


        PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(wil,
                height, 1).create();

    // create a new page from the PageInfo
        PdfDocument.Page page = document.startPage(pageInfo);

    // repaint the user's text into the page
        content.draw(page.getCanvas());

    // do final processing of the page
        document.finishPage(page);

    // saving pdf document to sdcard
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy - HH-mm-ss",Locale.getDefault());
        String pdfName = "Revisões_" …
Run Code Online (Sandbox Code Playgroud)

android pdf-generation android-studio android-recyclerview

6
推荐指数
1
解决办法
4508
查看次数