Use the scene:
1. Create a custom picture.
2, custom clickable Imagespan, meaning to customize a dynamically generated picture.
Wait a minute
View view = Layoutinflater.from (Mcontext). Inflate (R.layout.xxxxxxxxx,NULL); ((ImageView) View.findviewbyid (r.id.xxxxxxxxx)). Setimagebitmap (Result.iconbitmap); ((TextView) View.findviewbyid (r.id.xxxxxxxxx)). SetText (Result.equip_name); //measure the size of a view intSpec = View.MeasureSpec.makeMeasureSpec (0, View.MeasureSpec.UNSPECIFIED); View.measure (spec, spec); //call the layout of the viewView.layout (0, 0, View.getmeasuredwidth (), View.getmeasuredheight ()); //Create paint to draw the interfaceBitmap B =Bitmap.createbitmap (View.getmeasuredwidth (), View.getmeasuredheight (), Bitmap.Config.ARGB_8888); Canvas C=NewCanvas (b); C.translate (-VIEW.GETSCROLLX (),-view.getscrolly ()); View.draw (c); View.setdrawingcacheenabled (true); //gets the cache of the bitmap and copies a copy of theBitmap cachebmp =View.getdrawingcache (); Bitmap viewbmp= Cachebmp.copy (Bitmap.Config.ARGB_8888,true); //release the drawing's cacheView.destroydrawingcache (); bitmapdrawable BD=Newbitmapdrawable (Mcontext.getresources (), viewbmp); Bd.setbounds (0, 0, Bd.getintrinsicwidth (), Bd.getintrinsicheight ()); //put CacheBitmapcache cache =mbitmapcache.get (source); if(Cache! =NULL&& Cache.bitmap! =NULL) {cache.bitmap.clear (); } Cache=NewBitmapcache (); Cache.bitmap=NewWeakreference<bitmap>(Bd.getbitmap ()); Cache.scale= 1.0f; Mbitmapcache.put (source, cache); if(Mlistener! =NULL) {Mlistener.onloadingcomplete (NULL,NULL, viewbmp); }
1, drawable is a can be drawn object, it may be a bitmap (bitmapdrawable), it may be a graph (shapedrawable), there may be a layer (layerdrawable), we based on the demand for paint, Create the appropriate object to draw
2, canvas canvas, the destination area of the drawing, for drawing
3, Bitmap bitmap, for the processing of graphs
SetBounds (), this method is to determine the size of the picture, if not set, then the picture is 0 long width! Of course, you can adjust the image size by this method if the effect is too large or too small for you to display.
Android in bitmap and drawable
http://dyh7077063.iteye.com/blog/970672
View conversion to image for some functionality