Need to ImageView show round pictures as follows
Public StaticBitmap Toroundcorner (Bitmap Bitmap,floatratio) {System. out. println ("does the picture turn into a circular pattern +++++++++++++"); Bitmap Output=Bitmap.createbitmap (Bitmap.getwidth (), Bitmap.getheight (), Bitmap.Config.ARGB_8888); Canvas Canvas=NewCanvas (output); Final Paint Paint=NewPaint (); Final rect rect=NewRect (0,0, Bitmap.getwidth (), Bitmap.getheight ()); Final RECTF RECTF=NewRECTF (rect); Paint.setantialias (true); Canvas.drawargb (0,0,0,0); Canvas.drawroundrect (RECTF, Bitmap.getwidth ()/ratio, bitmap.getheight ()/ratio, paint); Paint.setxfermode (NewPorterduffxfermode (PorterDuff.Mode.SRC_IN)); Canvas.drawbitmap (Bitmap, rect, rect, paint); System. out. println ("pixels+++++++"+string.valueof (ratio)); returnoutput; }
If the picture is square, set the ratio to 2, if the picture is not a square, do it yourself! Cut the picture into the desired square. Show rounded edge length 1/4, then pass in 8, and so on!
Android ImageView Show round picture