Github

Github 好用分享AvatarView(圓形頭像)

1.先導入函示庫(build.gradle: Project)

repositories {
    maven { url "https://dl.bintray.com/vitorhugods/AvatarView" }
}

2.先導入函示庫(build.gradle: Module)

dependencies {
   implementation "xyz.schwaab:avvylib:1.0.0"
}

3.程式碼範例

a.Layout

 <xyz.schwaab.avvylib.AvatarView
        app:avvy_border_thickness="0dp"
        app:avvy_border_thickness_highlight="0dp"
        app:avvy_distance_to_border="0dp"
        android:id="@+id/avatarView"
        android:layout_width="128dp"
        android:layout_height="128dp"
        android:layout_marginTop="16dp"
        android:src="@drawable/d27"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

b.設置點擊監聽

avatarView.setOnClickListener {
     Toast.makeText(this, "被點擊了", Toast.LENGTH_SHORT).show()
}

4.效果展示

發表迴響