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

前端 未结 7 712
鱼传尺愫
鱼传尺愫 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

    had the same problem and finally this partly works for me:

    view.layout(0, 0, 1000, 100);
    Bitmap b = view.getDrawingCache();
    try {
        b.compress(CompressFormat.JPEG, 95,
        new FileOutputStream( Environment.getExternalStorageDirectory()                                                            + "/folder/name.jpg"));
    catch (FileNotFoundException e) {
        Log.e(LOGTAG, "error:" + e.getMessage());
        }
    

    the only problem is, that I can't get the full dimensions of my view. view.getwidth returns null ...

    0 讨论(0)
提交回复
热议问题