Reputation: 83
I'm trying to make an image circular in the simplest way. But it just won't work. I've also tried implementing "hdodenhof/CircleImageView" and it was of no use. Is there any alternate reliable way of doing this?
<com.google.android.material.card.MaterialCardView
android:layout_width="200dp"
android:layout_height="200dp"
app:cardCornerRadius="100dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/spongebob"/>
</com.google.android.material.card.MaterialCardView>
Upvotes: 0
Views: 87
Reputation: 1799
try to use CircularImageView
library:
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/spongebob"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp"
app:civ_shadow="true"
app:civ_shadow_radius="5"
app:civ_shadow_color="#ff9999"/>
and in build.gradle :
implementation 'com.mikhaellopez:circularimageview:3.2.0'
Upvotes: 0
Reputation: 180
Have you seen ImageView in circular through xml or Use library CircularImageView created by Henning Dodenhof. You just need to write few lines of code in your xml
<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"/>
Upvotes: 0