我想救我的活動的一部分,沒有工具欄和狀態欄。我現在擁有的代碼可以保存整個屏幕。請參考下面的圖片。保存一部分圖像
代碼,我現在所擁有的:
llIDCardRootView = (LinearLayout) view.findViewById(R.id.ll_id_card_root_view);
llIDCardContainer = (LinearLayout) llIDCardRootView.findViewById(R.id.ll_id_card_view);
private void createBitmap() {
Log.d(Const.DEBUG, "Creating Bitmap");
Bitmap bmp;
//View v = llIDCardContainer.getRootView();
//View v = activity.getWindow().getDecorView().findViewById(android.R.id.content);
//View v = activity.findViewById(R.id.ll_id_card_root_view);
ViewGroup v = (ViewGroup) ((ViewGroup) activity
.findViewById(android.R.id.content)).getChildAt(0);
v.setDrawingCacheEnabled(true);
// v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
// View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
// v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
// v.buildDrawingCache(true);
bmp = Bitmap.createBitmap(v.getDrawingCache());
File directory = new File(Environment.getExternalStorageDirectory()
+ File.separator);
File file = new File(directory, FILE_NAME);
try {
FileOutputStream out = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
v.destroyDrawingCache();
v.setDrawingCacheEnabled(false);
}
是保存圖像..
我如何才能挽救我需要的部分從片段?
作物的形象和保存,這將是更好的 – Sree