Android View.getDrawingCache returns null, only null

后端 未结 10 934
遇见更好的自我
遇见更好的自我 2020-11-22 13:06

Would anyone please try to explain to me why

public void addView(View child) {
  child.setDrawingCacheEnabled(true);
  child.setWillNotCacheDrawing(false);
          


        
10条回答
  •  攒了一身酷
    2020-11-22 13:41

    Im using this instead.

    myView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                Bitmap bitmap = Bitmap.createBitmap(myView.getDrawingCache());
            }
        });
    

提交回复
热议问题