5
我正在研究一個相當簡單的應用程序。該應用程序具有引擎蓋下下面的一段代碼:「位圖大小超過32位」在KitKat設備上的buildDrawingCache
...
mRootContentView = getWindow().getDecorView().findViewById(android.R.id.content));
int[] screenDimensions = AndroidUtils.getScreenDimesions(getContext());
bitmap = Bitmap.createBitmap(screenDimensions[0], screenDimensions[1], Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
mRootContentView.layout(0, 0, screenDimensions[0], screenDimensions[1]);
mRootContentView.draw(c);
...
正如你毫無疑問已經猜到了,它得到一個當前整個活動的「屏幕截圖」。
android的V I已經在我的ACRA面臨着一個奇怪的例外4.4.2(KitKat)的realease報告,告訴我這後:
java.lang.IllegalArgumentException: bitmap size exceeds 32bits
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:809)
at android.graphics.Bitmap.createBitmap(Bitmap.java:769)
at android.view.View.buildDrawingCache(View.java:13608)
at android.view.View.draw(View.java:14154)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at net.simonvt.menudrawer.MenuDrawer.dispatchDraw(MenuDrawer.java:665)
at android.view.View.draw(View.java:14468)
at android.view.View.draw(View.java:14350)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14468)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
. . .
該異常僅拋出一個奇巧設備,例如爲的Nexus 7和Nexus 5
編輯
我也試過這樣:
mRootContentView.setDrawingCacheEnabled(true);
mRootContentView.buildDrawingCache();
bitmap = mRootContentView.getDrawingCache();
沒有什麼改變。
在佈局之前應該測量 –