製作圓形用戶頭像
步驟
- 添加圓形圖片控件的依賴
在Moudle的build.gradle中添加如下代碼:
dependencies {
compile 'com.makeramen:roundedimageview:2.2.1'
}
- 在需要使用圓形控件的佈局文件中,設置命名空間app:
xmlns:app="http://schemas.android.com/apk/res-auto"
- 引用此控件,代碼舉例:
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_launcher"
app:riv_border_color="#000000"
app:riv_border_width="5dp"
app:riv_oval="true" />
效果
參考
詳情可參考博客分分鐘帶你搞定Android開發圓形頭像