I am trying to save part of my activity without a toolbar and status bar. The code I have now saves the entire screen. See image below.

The code I have right now is:
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); }
The saved image.

How can I just save the part that I need from the fragment?
source share