How to cut round:
Public Bitmap Toroundbitmap (Bitmap Bitmap) {int width = bitmap.getwidth (); int height = bitmap.getheight (); float roundpx;f Loat left, top, right, bottom, Dst_left, Dst_top, Dst_right, dst_bottom;if (width <= height) {roundpx = Width/2;left = 0;top = 0;right = Width;bottom = Width;height = Width;dst_left = 0;dst_top = 0;dst_right = Width;dst_bottom = width;} else {roundpx = height/2;float clip = (width-height)/2;left = Clip;right = Width-clip;top = 0;bottom = Height;widt H = height;dst_left = 0;dst_top = 0;dst_right = Height;dst_bottom = height;} Bitmap output = bitmap.createbitmap (width, height, config.argb_8888); Canvas canvas = new canvas (output), final paint paint = new paint (), final rect src = new rect ((int) left, (int) top, (int) Right, (int) bottom); final rect dst = new rect ((int) dst_left, (int) dst_top, (int) dst_right, (int) dst_bottom); final RECTF RECTF = new RECTF (DST);p Aint.setantialias (TRUE);//Set Brush non-aliased canvas.drawargb (0, 0, 0, 0); Fill the entire canvas//below there are two ways to draw a circle, drawrounrectand Drawcirclecanvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint);//Draw rounded rectangles, the first parameter is a graphic display area, the second parameter and the third parameter are the horizontal fillet radius and the vertical fillet radius, respectively. Canvas.drawcircle (ROUNDPX, ROUNDPX, ROUNDPX, paint);p Aint.setxfermode (New Porterduffxfermode (mode.src_in));// Set the pattern at which two pictures intersect, refer to Http://trylovecatch.iteye.com/blog/1189452canvas.drawBitmap (bitmap, SRC, DST, paint); Merge bitmap and Circlereturn output with draw in mode.src_in mode;}
Operation in the thread of the data request:
New Thread () {public void run () {HttpClient client = new Defaulthttpclient (); HttpGet get = new HttpGet (URL), try {httpresponse res = Client.execute (get), if (Res.getstatusline (). Getstatuscode () = = 200 ) {String str = entityutils.tostring (res.getentity ()); Gson g = new Gson (); Shop_list show_list = G.fromjson (str, shop_list.class); list = Show_list.getdata (). getcontent (); for (int i = 0; i < list . Size (); i++) {String url = "http://www.07snow.com/public/goods_image/" + list.get (i). Getgoods_imgs (); URL u = new url (URL); InputStream is = U.openstream (); Bitmap B1 = Bitmapfactory.decodestream (IS); Bitmap B2 = Toroundbitmap (B1); List.get (i). Setbit (B2);} List1.addall (list); Handler.sendmessage (Handler.obtainmessage (1));}} catch (Clientprotocolexception e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (IOException e) {//TODO Auto-generated catch Blocke.printstacktrace ();}};}. Start ();
Called in the handler main thread
About the ListView in the picture Tangent Circle, the network requests the data, and Gson resolves to get the list