Android View.getDrawingCache returns null, only null

后端 未结 10 988
遇见更好的自我
遇见更好的自我 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

    @cV2 and @nininho's answers both work for me.

    One of the other reasons that i found out the hard way was that the view that i had was generating a view that has width and height of 0 (i.e. imagine having a TextView with a string text of an empty string). In this case, getDrawingCache will return null, so just be sure to check for that. Hope that helps some people out there.

提交回复
热议问题