Android开发:View内容生成图片

生成图片的操作比较耗时,虽然是View对象,但咱是直接把View对象转成图片,不涉及修改UI显示,可以异步处理。

contentLayout.setDrawingCacheEnabled(true);     
contentLayout.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),     
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));     
contentLayout.layout(0, 0, contentLayout.getMeasuredWidth(),     
                contentLayout.getMeasuredHeight());     
contentLayout.buildDrawingCache();     
Bitmap bitmap= contentLayout.getDrawingCache();    

© 2015, 冰冻鱼. 请尊重作者劳动成果,复制转载保留本站链接! 应用开发笔记