Skip to content

Instantly share code, notes, and snippets.

@dmpatel151282
Created September 9, 2016 04:29
Show Gist options
  • Save dmpatel151282/63367672388e8a2ba55c1fd97f266c20 to your computer and use it in GitHub Desktop.
Save dmpatel151282/63367672388e8a2ba55c1fd97f266c20 to your computer and use it in GitHub Desktop.
Bitmap snapshot = null;
Drawable drawable = null;
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_AUTO); // Quality of the snpashot
try {
view.layout(0, 0, 110, 110);
snapshot = Bitmap.createBitmap(view.getDrawingCache(true)); // You can tell how to crop the snapshot and whatever in this method
drawable = new BitmapDrawable(snapshot);
} catch(Exception ex) {
ex.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment