getDrawinCache返回NULL,仅为NULL有谁能告诉我为什么public void addView(View child) {
child.setDrawingCacheEnabled(true);
child.setWillNotCacheDrawing(false);
child.setWillNotDraw(false);
child.buildDrawingCache();
if(child.getDrawingCache() == null) { //TODO Make this work!
Log.w("View", "View child's drawing cache is null");
}
setImageBitmap(child.getDrawingCache()); //TODO MAKE THIS WORK!!!}总是记录绘图缓存为NULL,并将位图设置为NULL?是否必须在设置缓存之前实际绘制视图?谢谢!
3 回答
侃侃尔雅
TA贡献1801条经验 获得超16个赞
v.setDrawingCacheEnabled(true);// this is the important code :) // Without it the view will have a dimension of 0,0 and the bitmap will be null v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); v.buildDrawingCache(true);Bitmap b = Bitmap.createBitmap(v.getDrawingCache());v.setDrawingCacheEnabled(false); // clear drawing cache
汪汪一只猫
TA贡献1898条经验 获得超8个赞
view.layout(0, 0, width, height);
- 3 回答
- 0 关注
- 492 浏览
添加回答
举报
0/150
提交
取消