效果图:
![](https://i-blog.csdnimg.cn/blog_migrate/7a7ed3e4549e09b62d68cb724e36f3a6.png)
代码:
/**
* 图片上左上右圆角
*/
public class RoundImageView extends AppCompatImageView {
float width, height;
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);
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bo