老套路看图:
实现方法非常简单,使用ClipPath切割就可以了:
完整代码如下:dpUtils工具类就不发了,自己写下吧
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.ImageView;
import com.gfan.xiayiye5.utils.DpUtils;
/**
* @author xiayiye5
* 2020年11月14日15:21:42
* 自定义圆角图片
*/
@SuppressLint("AppCompatCustomView")
public class RadiusImageView extends ImageView {
/**
* 圆角大小
*/
private int radiusSize = DpUtils.dip2px(getContext(), 10);
public RadiusImageView(Context context) {
super(context, null);
}
public RadiusImageView(Context context, @Nullable AttributeSet attrs) {