I am developing an Android App. In my app I am using CardView
and ImageView
together. But I am having a problem in designing ImageView
inside CardView
. The problem is with corner radius radius of ImageView
.
I have XML layout for adapter item like this.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
card_view:cardCornerRadius="5dp"
android:layout_width="match_parent"
android:id="@+id/di_card_container"
android:layout_height="wrap_content">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/di_iv_image"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:padding="10dp"
android:layout_below="@id/di_iv_image"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:id="@+id/di_name_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="15dp"
android:textColor="@color/textColorPrimary"
android:id="@+id/di_tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
As you can see I set, corner radius of CardView
to 5dp
and the ImageView
with is fit to the width of its parent CardView
. The problem is both top corners of ImageView
is not bent like its parent CardView
's corner.
This is the screenshot
Normally corners of child views of CardView
automatically bent like its parent corners if it fit to parent CardView
. Is that right? So why is my ImageView
is not working?