View v = rootView.findViewById(R.id.layout1);
if (v != null) {
v.buildDrawingCache();
Bitmap bitmap = v.getDrawingCache();
canvas.drawBitmap(bitmap, dummyMatrix, null);
v.destroyDrawingCache();
}
Run Code Online (Sandbox Code Playgroud)
我有这个代码.但是我需要截取我的所有ListView项目,但是如果我的列表视图中有多个项目而不是屏幕上可见的项目,则当代码大于可见矩形时,此代码不会捕获.
如何正确捕获我的ListView?
我创建的新工作代码
public static Bitmap getWholeListViewItemsToBitmap() {
ListView listview = MyActivity.mFocusedListView;
ListAdapter adapter = listview.getAdapter();
int itemscount = adapter.getCount();
int allitemsheight = 0;
List<Bitmap> bmps = new ArrayList<Bitmap>();
for (int i = 0; i < itemscount; i++) {
View childView = adapter.getView(i, null, listview);
childView.measure(MeasureSpec.makeMeasureSpec(listview.getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
childView.setDrawingCacheEnabled(true);
childView.buildDrawingCache();
bmps.add(childView.getDrawingCache());
allitemsheight+=childView.getMeasuredHeight();
}
Bitmap bigbitmap = …Run Code Online (Sandbox Code Playgroud) 我想创建活动的“整页” 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) 这里已经提出了问题:创建完整长度的 RecyclerView PDF 我也有同样的问题,因为我还没有找到解决方案,我想生成完整长度的 RecyclerView 内容的 PDF。但没有找到解决方案。
我已经尝试了所有可用的解决方案以及从 RecycleView 生成 PDF 的所有可能方法。
我已经尝试过的解决方案:
https://gist.github.com/PrashamTrivedi/809d2541776c8c141d9a
已经尝试了上面提到的所有解决方案,但其中任何一个都不适合我,并且出现错误,有时宽度和高度问题,或者有时得到空的白色位图作为输出不知道为什么。
问题 :
我有 RecyclerView 与 HTML 内容以及内容之间的图像。
将以下屏幕视为包含内容的 RecyclerView。
RecyclerView 中的内容与上图相同,包含 100 多个项目。
RecyclerView 项目布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/leftImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:maxHeight="350dp"
fresco:actualImageScaleType="fitCenter"
fresco:placeholderImage="@color/white" />
<jp.wasabeef.richeditor.RichEditor
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin10dp"
android:layout_marginRight="@dimen/margin10dp"
android:layout_weight="1"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/rightImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:maxHeight="350dp"
fresco:actualImageScaleType="fitCenter"
fresco:placeholderImage="@color/white" />
</LinearLayout> …Run Code Online (Sandbox Code Playgroud)