自定义圆形的ImageVIew

/**
 * 圆形ImageView
 */
public class CircleImageView extends ImageView {
   

    private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;      //只允许CENTER_CROP模式
    private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;  //默认创建的格式
    private static final int COLORDRAWABLE_DIMENSION = 2;   //对于 colorDrawable 的大小

    //以下是自定义属性
    private int mBorderWidth = 3;            //默认边框的宽度,单位 dp
    private int mBorderColor = 0xFFFF0000;   //默认边框的颜色
    private int mFillColor = 0x00000000;     //纯色的填充色
    private boolean mBorderOverlay = false;  //true表示边框会覆盖一部分图片,false表示边框不会覆盖在图片之上

    //以下是成员变量
    private final Matrix mShaderMatrix = new Matrix();  //对图片缩放的矩阵
    private final Paint mBitmapPaint = new Paint();     //图片的画笔
    private final Paint mBorderPaint = new Paint();     //边框的画笔
    private final Paint mFillPaint = new Paint();       //背景色的画笔
    private Bitmap mBitmap;            //设置的图片
    private float mBorderRadius;       //边框的半径,默认向内部偏移了 mBorderWidth/2 的长度,保证边框不超出有效绘画区域
    private float mDrawableRadius;     //内容的绘制半径,自动根据 mBorderOverlay 参数决定是否包括边框的半径
    private ColorFilter mColorFilter;  //滤色
    private boolean mSetupPending;     //是否执行了setUp方法

    public CircleImageView(Context context) {
        this(context, 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值