Create custom_selector.xml in the drawing folder
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/unselected" android:state_pressed="true" /> <item android:drawable="@drawable/selected" /> </selector>
Create a selected.xml form in a folder with the ability to move
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="90dp"> <solid android:color="@color/selected"/> <padding /> <stroke android:color="#000" android:width="1dp"/> <corners android:bottomRightRadius="15dp" android:bottomLeftRadius="15dp" android:topLeftRadius="15dp" android:topRightRadius="15dp"/> </shape>
Create an unselected.xml form in a folder with the ability to move
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="90dp"> <solid android:color="@color/unselected"/> <padding /> <stroke android:color="#000" android:width="1dp"/> <corners android:bottomRightRadius="15dp" android:bottomLeftRadius="15dp" android:topLeftRadius="15dp" android:topRightRadius="15dp"/> </shape>
Add the following colors for the selected / unselected state in the color.xml values folder
<color name="selected">#a8cf45</color> <color name="unselected">#ff8cae3b</color>
you can check the complete solution from here
nirav kalola Oct. 14 '15 at 5:46 2015-10-14 05:46
source share