0
我需要將佈局的內容保存到位圖以供以後使用,但是,我面臨的問題是所述佈局比設備屏幕大。將比設備屏幕大的佈局保存爲位圖
瀏覽通過計算器的問題,我已經來到了下面的代碼:
private void viewToBitmap(View view) {
view.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + name + ".jpg";
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
}
它的工作原理適用於那些比設備的屏幕大小相同或更小的佈局,但是當我嘗試將佈局轉換我需要的,我得到以下錯誤:
LinearLayout not displayed because it is too large to fit into a software layer (or drawing cache), needs 9334080 bytes, only 3686400 available
在所有這甚至可能還是我必須發揮創意,做類似的東西適應屏幕使用多個佈局和保存到多個位圖分別?