Android: How to Make A Drawable Selector

You can add this in Android Studio, use Right click on project structure -> New -> Drawable resource file. It should look like this: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_enabled=”false” android:drawable=”@drawable/cell_top_selected” /> <item android:drawable=”@drawable/cell_top” /> </selector>

Using drawable resources

To avoid error: Binary XML file line #XXX: requires a valid src attribute inside a layer-list, use: <item android:drawable=”https://stackoverflow.com/questions/9788726/@drawable/image” /> instead of: <item> <bitmap android:src=”https://stackoverflow.com/questions/9788726/@drawable/image”/> </item>

Android shape border with gradient

try something like this: <?xml version=”1.0″ encoding=”UTF-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape android:shape=”rectangle” > <gradient android:angle=”360″ android:centerColor=”#e95a22″ android:endColor=”#ff00b5″ android:gradientRadius=”360″ android:startColor=”#006386″ android:type=”sweep” /> <stroke android:width=”2dp” android:color=”#ff207d94″ /> </shape> </item> <item android:bottom=”2dp” android:left=”2dp” android:right=”2dp” android:top=”2dp”> <shape android:shape=”rectangle” > <solid android:color=”#fff” /> </shape> </item> </layer-list>