getDrawinCache返回NULL,僅為NULL有誰(shuí)能告訴我為什么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,并將位圖設(shè)置為NULL?是否必須在設(shè)置緩存之前實(shí)際繪制視圖?謝謝!
3 回答

侃侃爾雅
TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超16個(gè)贊
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貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
view.layout(0, 0, width, height);
- 3 回答
- 0 關(guān)注
- 515 瀏覽
添加回答
舉報(bào)
0/150
提交
取消