java - Custom button drawable state_pressed and state_checked not working on CheckBox or RadioButton - Android -
i setting custom drawable checkbox button,
android:state_checked="true"
, android:state_checked="false"
seem work.
other states aren't working.
i unable set custom drawable on pressed state.
this selector using:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/radio_btn_selected" /> <item android:state_checked="false" android:drawable="@drawable/radio_btn_normal" /> <item android:state_pressed="true" android:drawable="@drawable/radio_btn_pressed" /> <item android:state_focused="true" android:drawable="@drawable/radio_btn_pressed" /> <item android:drawable="@drawable/radio_btn_normal"/> <!-- default --> </selector>
this how setting radio button:
radiobutton.setbuttondrawable(r.drawable.radio_btn_selectors);
android:state_pressed="true"
, android:state_focused="true"
not working because of ordering in declared various states. whenever declare drawable this, system goes top bottom , if state matched, doesn't other ones , applies changes based on first selection. think here android:state_checked="false"
condition might executing instead of android:state_pressed="true"
, android:state_focused="true"
. move android:state_checked="false"
bottom , try.
Comments
Post a Comment