this is my xml drawbale code with the name of btntheme.xml :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_enabled="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light" android:state_enabled="false" android:state_window_focused="false"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_pressed_holo_light" android:state_pressed="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_focused_holo_light" android:state_enabled="true" android:state_focused="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_enabled="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_focused_holo_light" android:state_focused="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light"/>
</selector>
I've put all those images with the these names in the drawable-hdpi folder .
this is my layout and the button :
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:background="@drawable/btntheme"
android:textSize="@dimen/font_size_smallerButton" />
it's not working , it doesn't change the button theme at all ?
could you help me to solve it ?
thank you
Try out selector as below:
For more detail guidenc check out Custom Selector in Android
Create drawable folder in res and put btntheme.xml in that folder .
Ok I also suffered form this problem, remove android:state_focused="true" line form your code and run. hope get the answer :), (i think focus is only for input type views in my knowledge if i wrong plz guide me) for testing focus state press TAB key this is sample:-
The problem might be that the screen you are testing on does not use drawable-hdpi, so try to move the images and xml file itself to the drawable folder, if it does not exist then create it.
try to add
<?xml version="1.0" encoding="utf-8"?>
in xml file and xml file will likeafter using this if it will not work then if possible try to use image view instead of button i think that will be work. thanks;-)