四十二、【ImageView设置圆角】

431 阅读1分钟

CircleImageView:https://github.com/hdodenhof/CircleImageView

常见的属性:

<declare-styleable name="CircleImageView">
        <attr name="civ_border_width" format="dimension" />
        <attr name="civ_border_color" format="color" />
        <attr name="civ_border_overlay" format="boolean" />
        <attr name="civ_fill_color" format="color" />
    </declare-styleable>

1.添加依赖:

dependencies {
    ...
    compile 'de.hdodenhof:circleimageview:2.1.0'
}

2.使用

<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="2dp"
    app:civ_border_color="#FF000000"/>