There are a lot of software on PC, but there are few on Android, so I wrote one myself. The following is the core code of the software: Private bitmap getviewbitmap (view V) {// convert a view into an image
V. clearfocus (); // clear view focus
V. setpressed (false); // set the view to not clickable
Boolean willnotcache = V. willnotcachedrawing (); // whether the returned view can save its drawing Cache
V. setwillnotcachedrawing (false );
// Reset the drawing cache background color to fully transparent
// For the duration of this operation // set the view to transparent during this operation
Int color = V. getdrawingcachebackgroundcolor (); // obtain the background color of the cached bitmap.
V. setdrawingcachebackgroundcolor (0); // set the drawing background color.
If (color! = 0) {// If the obtained background is not black, release the previous drawing cache.
V. destroydrawingcache (); // release the cache used by the drawing Resource
}
V. builddrawingcache (); // recreate the drawing cache. The background color is black.
Bitmap cachebitmap = V. getdrawingcache (); // cache the drawing. Note that only an image is referenced here.
If (cachebitmap = NULL ){
Return NULL;
}
Bitmap bitmap = bitmap. createbitmap (cachebitmap); // instantiate a bitmap.
// Restore the view
V. destroydrawingcache (); // release the bitmap memory.
V. setwillnotcachedrawing (willnotcache); // return the previous cache settings
V. setdrawingcachebackgroundcolor (color); // return the previous cache color settings
Return bitmap;
}
Http://xiangqianppp-163-com.iteye.com/blog/1457688