1 重写ImageView
public class RoundImageView extends AppCompatImageView { float width, height; private int defaultRadius = 0; private int radius; private int leftTopRadius; private int rightTopRadius; private int rightBottomRadius; private int leftBottomRadius; public RoundImageView(Context context) { this(context, null); init(context, null); } public RoundImageView(Context context, AttributeSet attrs) { this(context, attrs, 0); init(context, attrs); } public RoundImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs); } private void init(Context context, AttributeSet attrs) { if (Build.VERSION.SDK_INT < 18) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } // 读取配置 TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.Custom_Round_Image_View); radius = array.getDimensionPixelOffset(R.styleab