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(R.id.text);
View img = (View) findViewById(R.id.view);
img = tv.getRootView();
img.setDrawingCacheEnabled(true);
Bitmap bmp = img.getDrawingCache();
ImageView image = (ImageView) findViewById(R.id.img);
image.setImageBitmap(bmp);

Comments

Popular posts from this blog

AlarmManager and Notification in Android

Swipe Action and ViewFlipper in Android

Open Gallery and get the selected image in appplication