Monday, May 9, 2011

Capture Screen in Android

Capturing screen is a very useful thing in lot of projects. We can use it for thumbnail, in some cases can use it for Animations etc. This post mainly shows the power of setDrawingCacheEnabled() method in Android's View class. Most common use is take the screen shot and use it as a thumbnail. Take a view from the layout xml file and use the code snippet,

TextView tv = (TextView) findViewById(;
View img = (View) findViewById(;
img = tv.getRootView();
Bitmap bmp = img.getDrawingCache();
ImageView image = (ImageView) findViewById(;

No comments:

Post a Comment