I am trying to make a gridview which will have an image and text beneath it with corner radius effect. So far it seems not possible. Here is my Activity xml which is holding the gridview:
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnWidth="140dp"
android:padding="5dp"
android:layout_marginTop="10dp"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
android:stretchMode="columnWidth"
android:gravity="center"/>
</ScrollView>
Here is the adapter xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_height="wrap_content"
android:padding="2dp"
android:layout_margin="20dp"
android:background="@drawable/grid_corner_radius"
android:layout_width="wrap_content">
<ImageView
android:layout_width="200dp"
android:background="@drawable/cat_life"
android:layout_height="160dp"/>
<TextView
android:layout_width="200dp"
android:layout_height="40dp"
android:id="@+id/credit_textView"
android:gravity="center"
android:text="Life"
android:textColor="#FFFFFF"
android:background="@color/colorPrimary"
android:textSize="15dp"/>
</LinearLayout>
And finally here is the corner radius magic code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#C0C0C0"></solid>
<corners android:radius="15dp"></corners>
</shape>
</item>
</selector>
And the output is as under:
See the image's sharp rectangle edge is visible. What could be the possible solution?
