Method 1:
Picture snapShot = view. capturePicture ();
If (snapShot. getWidth ()> 0 & snapShot. getHeight ()> 0 ){
Bitmap B = Bitmap. createBitmap (snapShot. getWidth (),
SnapShot. getHeight (), Bitmap. Config. ARGB_8888 );
Canvas c = new Canvas (B );
SnapShot. draw (c );
Bitmap newBitmap = zoomBitmap (B, 250,250 );
HistoryModel. setSnapshot (newBitmap );
Method 2 (after testing, the flat vertical screen often fails because the size of root. getDrawingCache () exceeds the limit ):
View root = activity. getWindow (). getDecorView ();
Private Bitmap catchScreen (View root ){
Root. setDrawingCacheEnabled (true );
Root. setDrawingCacheBackgroundColor (0 );
Root. buildDrawingCache (true );
Bitmap B = root. getDrawingCache ();
Return B;
}
Method 3 (high success rate ):
// Create snapshot for webview
View cv = activity. getWindow (). getDecorView ();
Bitmap B = Bitmap. createBitmap (cv. getWidth (), cv. getHeight (),
Config. ARGB_4444 );
Cv. draw (new Canvas (B ));
Author: fhy_2008