android - State_pressed change color of a view -
i have selector
xml file applied relativelayout
background element:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> <solid android:color="#449def" /> <stroke android:width="1dp" android:color="#2f6699" /> <corners android:radius="3dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> <item android:state_pressed="false"> <shape> <gradient android:startcolor="#f3ae1b" android:endcolor="#bb6008" android:angle="270" /> <stroke android:width="1dp" android:color="#bb6008" /> <corners android:radius="10dp" /> <padding android:left="0dp" android:top="10dp" android:right="0dp" android:bottom="10dp" /> </shape> </item> </selector>
my question is: why doesnt color of layout change when state changed?
you have make layout clickable. add:
android:clickable="true"
to relativelayout definition
Comments
Post a Comment