List of usage examples for android.widget LinearLayout getRootView
public View getRootView()
Finds the topmost view in the current view hierarchy.
From source file:org.drrickorang.loopback.LoopbackActivity.java
/** Save a screenshot of the main activity. */ void saveScreenShot(Uri uri) { ParcelFileDescriptor parcelFileDescriptor = null; FileOutputStream outputStream; try {/*from ww w. j a v a2s. co m*/ parcelFileDescriptor = getApplicationContext().getContentResolver().openFileDescriptor(uri, "w"); FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); outputStream = new FileOutputStream(fileDescriptor); log("Done creating output stream"); LinearLayout LL = (LinearLayout) findViewById(R.id.linearLayoutMain); View v = LL.getRootView(); v.setDrawingCacheEnabled(true); Bitmap b = v.getDrawingCache(); //save b.compress(Bitmap.CompressFormat.PNG, 100, outputStream); parcelFileDescriptor.close(); v.setDrawingCacheEnabled(false); } catch (Exception e) { log("Failed to open png file " + e); } finally { try { if (parcelFileDescriptor != null) { parcelFileDescriptor.close(); } } catch (Exception e) { e.printStackTrace(); log("Error closing ParcelFile Descriptor"); } } }