public class RoundCornerImageView extends ImageView { //这里是上边两个角是圆角 ,总共八个参数,后面四个决定了下面两个角的radius static final float[] f ={30f,30f,30f,30f,0f,0f,0f,0f}; public RoundCornerImageView(Context context) { super(context); } public RoundCornerImageView(Context context, AttributeSet attrs) { super(context, attrs); } public RoundCornerImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onDraw(Canvas canvas) { Path clipPath = new Path(); int w = this.getWidth(); int h = this.getHeight(); clipPath.addRoundRect(new RectF(0, 0, w, h), f , Path.Direction.CW); canvas.clipPath(clipPath); super.onDraw(canvas); } }