猿问

Android view 生成位图bitmap?

cynthiaty
浏览 1699回答 1
1回答

cynthiaty

/**  * 页面视图生成图片(view to bitmap)  */ public static Bitmap view_convert_bitmap(final View v) {     v.setDrawingCacheEnabled(true);     v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),             View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));     v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());     v.buildDrawingCache(true);     Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache());     v.setDrawingCacheEnabled(false); // clear drawing cache     return bitmap; }
随时随地看视频慕课网APP

相关分类

Android
我要回答