日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android 截图 listview,Android屏幕及view的截图实例详解

發布時間:2024/7/23 Android 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 截图 listview,Android屏幕及view的截图实例详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Android屏幕及view的截圖實例詳解

屏幕可見區域的截圖

整個屏幕截圖的話可以用View view = getWindow().getDecorView();

public static Bitmap getNormalViewScreenshot(View view) {

view.setDrawingCacheEnabled(true);

view.buildDrawingCache();

return view.getDrawingCache();

}

scrollview的整體截屏

public static Bitmap getWholeScrollViewToBitmap(View view) {

view.measure(MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED),MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED));

view.layout(0,view.getMeasuredWidth(),view.getMeasuredHeight());

view.buildDrawingCache();

Bitmap bitmap = view.getDrawingCache();

return bitmap;

}

webview的整體截圖

public static Bitmap getWholeWebViewToBitmap(WebView webView) {

Picture snapShot = webView.capturePicture();

Bitmap bmp = Bitmap.createBitmap(snapShot.getWidth(),snapShot.getHeight(),Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(bmp);

snapShot.draw(canvas);

return bmp;

}

listview的整體截圖

public static Bitmap getWholeListViewItemsToBitmap(ListView listview) {

ListAdapter adapter = listview.getAdapter();

int itemscount = adapter.getCount();

int allitemsheight = 0;

List bmps = new ArrayList();

for (int i = 0; i < itemscount; i++) {

View childView = adapter.getView(i,null,listview);

childView.measure(MeasureSpec.makeMeasureSpec(listview.getWidth(),MeasureSpec.EXACTLY),MeasureSpec.UNSPECIFIED));

childView.layout(0,childView.getMeasuredWidth(),childView.getMeasuredHeight());

childView.setDrawingCacheEnabled(true);

childView.buildDrawingCache();

bmps.add(childView.getDrawingCache());

allitemsheight += childView.getMeasuredHeight();

}

Bitmap bigbitmap = Bitmap.createBitmap(listview.getMeasuredWidth(),allitemsheight,Bitmap.Config.ARGB_8888);

Canvas bigcanvas = new Canvas(bigbitmap);

Paint paint = new Paint();

int iHeight = 0;

for (int i = 0; i < bmps.size(); i++) {

Bitmap bmp = bmps.get(i);

bigcanvas.drawBitmap(bmp,iHeight,paint);

iHeight += bmp.getHeight();

bmp.recycle();

bmp = null;

}

return bigbitmap;

}

需要多次截圖的話,需要用到 view.destroyDrawingCache();

Bitmap normalViewScreenshot = ScreenShotUtils.getNormalViewScreenshot(mFrameContent);

if (normalViewScreenshot != null) {

Bitmap b = Bitmap.createBitmap(normalViewScreenshot);

mImageResult.setImageBitmap(b);

mFrameContent.destroyDrawingCache();

}

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

總結

如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。

本圖文內容來源于網友網絡收集整理提供,作為學習參考使用,版權屬于原作者。

小編個人微信號 jb51ccc

喜歡與人分享編程技術與工作經驗,歡迎加入編程之家官方交流群!

總結

以上是生活随笔為你收集整理的android 截图 listview,Android屏幕及view的截图实例详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。