CircleImageView 设置无边框

来源:互联网 发布:数控精雕机编程 编辑:程序博客网 时间:2024/05/03 19:01


CircleImageView学习

在不需要边框时设置如下:


<de.hdodenhof.circleimageview.CircleImageView    xmlns:app="http://schemas.android.com/apk/res-auto"    android:id="@+id/profile_image"    android:layout_width="96dp"    android:layout_height="96dp"    android:src="@drawable/profile"    app:civ_border_width="0dp"    app:civ_border_color="#FF000000"/>

并注释掉

de.hdodenhof.circleimageview.CircleImageView代码中

@Override    protected void onDraw(Canvas canvas) {        if (getDrawable() == null) {            return;        }        canvas.drawCircle(getWidth() / 2, getHeight() / 2, mDrawableRadius, mBitmapPaint);        //canvas.drawCircle(getWidth() / 2, getHeight() / 2, mBorderRadius, mBorderPaint);注释掉    }

解释:app:civ_border_wdith="0dp" 只是设置圆形图片的边框大小,即环宽(边框相当于一个圆环)

当环宽为0时,是不应该绘制的,但是github代码中仍然在图片最外围描了下边,故应该注释掉onDraw中的代码


github地址 https://github.com/hdodenhof/CircleImageView
0 0
原创粉丝点击