Android 实现圆角头像(使用第三方开源库)

效果图:
Android 实现圆角头像(使用第三方开源库)_第1张图片

第一步,先导入第三方依赖:

implementation ‘com.makeramen:roundedimageview:2.2.1’

Android 实现圆角头像(使用第三方开源库)_第2张图片

第二步:
activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#05a7f2"
    tools:context=".MainActivity">

    <com.makeramen.roundedimageview.RoundedImageView
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:layout_centerInParent="true"
        android:src="@drawable/ic_kenan"
        app:riv_oval="true" />
    
</RelativeLayout>

MainActivity.java 不变

点击运行即可 !

其他相关API:

* riv_border_width: 边框宽度
* riv_border_color: 边框颜色
* riv_oval: 是否圆形
* riv_corner_radius: 圆角弧度
* riv_corner_radius_top_left:左上角弧度
* riv_corner_radius_top_right: 右上角弧度
* riv_corner_radius_bottom_left:左下角弧度
* riv_corner_radius_bottom_right:右下角弧度

最后,我真诚的希望能评论一句嘛,让我知道你来过,我会很开心的

你可能感兴趣的:(Android,学习)