Below this is my code:
<androidx.cardview.widget.CardView
android:layout_width="78dp"
android:layout_height="78dp"
android:layout_gravity="center"
app:cardBackgroundColor="?colorSecondary"
app:cardCornerRadius="250dp">
<ImageView
android:id="@+id/customer_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/content_description"
android:scaleType="centerCrop"
android:src="@drawable/ic_no_picture" />
</androidx.cardview.widget.CardView>
It works perfectly with API 30/29/28 but for API 27 i just have an empty CardView. Do you have any idea?
I just found a way to fix my problem, with API 27 to have circular image with cardView you have to put cardCornerRadius to a maximum of width / height. In my example i just write app:cardCornerRadius="39dp"
and it works perfectly.
There are many libraries on github which makes Imageview in circular shape. You can explore github.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.