I am trying to put selector on image which is rectangle it's working fine above lollipop but not in lollipop and lower version of it.
i used cardview with two images one with imageselector and one actual image.
anyone can guide me why it's not working properly!
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:tint="@color/transparent">
<solid android:color="@android:color/transparent" />
<stroke
android:width="3dp"
android:color="@color/black" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:tint="@color/transparent">
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="@color/white" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
</item>
</layer-list>
<android.support.v7.widget.CardView
android:id="@+id/image_selector_item_card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_margin="2dp"
android:clipToPadding="true">
<ImageView
android:id="@+id/image_selector_item_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
<ImageView
android:id="@+id/border_selected"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image_selector_selected_border"/>
</android.support.v7.widget.CardView>
You can simplify this to below tested code
dummy.xml inside drawable
<item>
<shape android:shape="rectangle">
<solid android:color="@color/white"/>
<stroke android:color="@color/black" android:width="3dp"/>
<corners android:radius="20dp"/>
</shape>
</item>
and
<android.support.v7.widget.CardView
android:id="@+id/image_selector_item_card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
app:cardCornerRadius="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/dummy">
<ImageView
android:id="@+id/image_selector_item_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="6dp"
android:scaleType="centerCrop" />
</LinearLayout>
</android.support.v7.widget.CardView>
let me know if it works