美文网首页Android 开发技术分享
Android第三方开源库CircleImageView的使用

Android第三方开源库CircleImageView的使用

作者: i小灰 | 来源:发表于2020-04-18 10:31 被阅读0次
image

目前最新版本是 3.0.1
具体以官方为准

GitHub:

https://github.com/hdodenhof/CircleImageView

快速圆形的 ImageView,非常适合个人资料图像。这基于 Vince Mi 的 RoundedImageView ,它本身基于 Romain Guy 推荐的技术。

使用流程:

1. 在 app/build.gradle 中添加:

dependencies {
    ...
    implementation 'de.hdodenhof:circleimageview:3.0.1'
}

2. 布局文件


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/profile_image"
            android:layout_width="96dp"
            android:layout_height="96dp"
            android:layout_centerInParent="true"
            android:src="@drawable/profile"
            app:civ_border_color="#FF000000"
            app:civ_border_width="2dp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:background="#000"
        android:layout_height="0dp"
        android:layout_weight="1">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/profile_image2"
            android:layout_width="96dp"
            android:layout_height="96dp"
            android:layout_centerInParent="true"
            android:src="@drawable/profile"
            app:civ_border_color="#ffffff"
            app:civ_border_width="2dp" />
    </RelativeLayout>
</LinearLayout>

3. 效果图

image

相关文章

网友评论

    本文标题:Android第三方开源库CircleImageView的使用

    本文链接:https://www.haomeiwen.com/subject/xszmvhtx.html