Android 2.1 View's getDrawingCache() method always returns null

前端 未结 7 747
鱼传尺愫
鱼传尺愫 2020-11-29 09:37

I\'m working with Android 2.1 and have the following problem: Using the method View.getDrawingCache() always returns null. getDrawingCache() should return a Bitmap, which is

7条回答
  •  不知归路
    2020-11-29 10:19

    Bitmap screenshot;
    view.setDrawingCacheEnabled(true);
    screenshot = Bitmap.createBitmap(view.getDrawingCache());
    view.setDrawingCacheEnabled(false);
    

    You need Bitmap.createBitmap(view.getDrawingCache()); as the Bitmap from which the reference is received by getDrawingCache() gets recycled.

提交回复
热议问题