Nonsense not to say more, directly to everyone to paste the code, the specific code as follows:
public class Roundimageview extends ImageView {private Paint Paint; private int roundwidth =; private int roundheight
= 50;
Private Paint Paint2; Public Roundimageview (context, AttributeSet attrs, int defstyle) {Super (context, attrs, defstyle); init (context,
ATTRS); Roundimageview (context, AttributeSet attrs) {Super (context, attrs), init (context, attrs); Setroundvalue (float roundvalue) {roundwidth = (int) roundvalue; roundheight = (int) roundvalue;} public Roundimageview (C Ontext context) {Super [context]; init (context, NULL);} @SuppressLint ("recycle") private void init (context, Attri Buteset attrs) {if (attrs!= null) {TypedArray a = Context.obtainstyledattributes (Attrs, R.styleable.roundangleimageview
);
Roundwidth = A.getdimensionpixelsize (R.styleable.roundangleimageview_roundwidth, roundWidth);
Roundheight = A.getdimensionpixelsize (R.styleable.roundangleimageview_roundheight, roundHeight); else {float density = context.getrEsources (). Getdisplaymetrics (). density;
Roundwidth = (int) (roundwidth * density);
Roundheight = (int) (roundheight * density);
} paint = new paint ();
Paint.setcolor (Color.White);
Paint.setantialias (TRUE);
Paint.setxfermode (New Porterduffxfermode (PorterDuff.Mode.DST_OUT));
Paint2 = new Paint ();
Paint2.setxfermode (NULL); @Override public void Draw (Canvas Canvas) {Bitmap Bitmap = Bitmap.createbitmap (GetWidth (), GetHeight (), config.argb_888
8);
Canvas canvas2 = new Canvas (bitmap);
Super.draw (CANVAS2);
Drawliftup (CANVAS2);
Drawrightup (CANVAS2);
Drawliftdown (CANVAS2);
Drawrightdown (CANVAS2);
Canvas.drawbitmap (bitmap, 0, 0, Paint2);
Bitmap.recycle ();
bitmap = null; } private void Drawliftup (Canvas Canvas) {Path PATH = new Path (); Path.moveto (0, roundheight); Path.lineto (0, 0); path.li
NeTo (roundwidth, 0);
Path.arcto (New RECTF (0, 0, roundwidth * 2, Roundheight * 2),-90,-90);
Path.close ();
Canvas.drawpath (path, paint); private void Drawliftdown (Canvas Canvas) {Path PATH = new Path (); PATh.moveto (0, GetHeight ()-roundheight);
Path.lineto (0, GetHeight ());
Path.lineto (Roundwidth, GetHeight ());
Path.arcto (New RECTF (0, GetHeight ()-roundheight * 2, 0 + roundwidth * 2, GetWidth ()), 90, 90);
Path.close ();
Canvas.drawpath (path, paint); } private void Drawrightdown (Canvas Canvas) {Path PATH = new Path (); Path.moveto (GetWidth ()-Roundwidth, GetHeight ()); p
Ath.lineto (GetWidth (), getheight ());
Path.lineto (GetWidth (), GetHeight ()-roundheight);
Path.arcto (New RECTF (GetWidth ()-Roundwidth * 2, GetHeight ()-Roundheight * 2, GetWidth (), GetHeight ()), 0, 90);
Path.close ();
Canvas.drawpath (path, paint); } private void Drawrightup (Canvas Canvas) {Path PATH = new Path (); Path.moveto (GetWidth (), roundheight); Path.lineto (GETW
Idth (), 0);
Path.lineto (GetWidth ()-roundwidth, 0);
Path.arcto (New RECTF (GetWidth ()-roundwidth * 2, 0, getwidth (), 0 + roundheight * 2),-90, 90);
Path.close ();
Canvas.drawpath (path, paint); }
}
OK, about the Android fillet ImageView class can set the content of radians small series to introduce to everyone here, I hope to help you!