About the ListView in the picture Tangent Circle, the network requests the data, and Gson resolves to get the list

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.