Issue
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
Solution
Try out selector as below:
<!-- Active tab -->
<item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
<!-- Inactive tab -->
<item android:drawable="@drawable/customactionbartheme_btn_default_pressed_holo_light" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
<!-- Pressed tab -->
<item android:drawable="@drawable/customactionbartheme_btn_default_pressed_holo_light" android:state_pressed="true"/>
<!-- Selected tab (using d-pad) -->
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
</selector>
For more detail guidenc check out Custom Selector in Android
Answered By - GrIsHu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.