Development, sometimes need to get the view to do animation to achieve the purpose of animation process, there are many other uses
/*** Convert view to bitmap object*/ Public classViewtobitmaputil {Private Static FinalString TAG = "Viewtobitmaputil"; Public StaticBitmap convertviewtobitmap (view view) {View.measure (Measurespec.makemeasurespec (0, Measurespec.unspecified), Measurespec.makemeasurespec (0, measurespec.unspecified)); View.layout (0, 0, View.getmeasuredwidth (), View.getmeasuredheight ()); View.builddrawingcache (); Bitmap Bitmap=View.getdrawingcache (); returnbitmap; } Public StaticBitmap Convertviewtobitmap (View view,intBitmapwidth,intbitmapheight) {Bitmap Bitmap=Bitmap.createbitmap (Bitmapwidth, Bitmapheight, Bitmap.Config.ARGB_8888); View.draw (NewCanvas (bitmap)); returnbitmap; } Public Static voidGetscreenrectofview (view view, Rect outrect) {intPos[] =New int[2]; View.getlocationonscreen (POS); Outrect.set (pos[0], pos[1], pos[0] + view.getwidth (), pos[1] +view.getheight ()); }
}
Get view-Convert view to bitmap object