0
首先,我的應用程序目前在清單文件中定義了anyDensity = false。在應用程序的其他地方,我試圖捕獲並顯示一個View的DrawingCache,但是我無法獲得清晰的位圖而沒有縮放工件。anyDensity = false爲什麼getDrawingCache(true)返回null?
下面的代碼產生一個位圖,但它具有縮放僞像,並且通常是模糊的。
myView.setDrawingCacheEnabled(true);
Bitmap myBitmap = Bitmap.Create(myView.getDrawingCache());
myImageView.setImageBitmap(myBitmap);
當我讀到它,爲getDrawingCache的文件說,這是可以預期的,並使用getDrawingCache(真)。但是,下面的兩個代碼示例都會拋出NullPointer異常,因爲getDrawingCache返回的位圖(true)始終爲空。
myView.setDrawingCacheEnabled(true);
Bitmap myBitmap = Bitmap.Create(myView.getDrawingCache(true));
myImageView.setImageBitmap(myBitmap);
OR
myView.buildDrawingCache(true);
Bitmap myBitmap = Bitmap.Create(myView.getDrawingCache(true));
myImageView.setImageBitmap(myBitmap);
myView.destroyDrawingCache();
有誰知道如何正確地捕捉和渲染drawingCache時anyDensity =假?