I am creating a spinner with a custom view, anyway I managed to show different drawables for when the spinner is inactive and also for when it's pressed, I would like to keep the pressed state drawable when the dropdown list shows. Here is mi XML file:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/ComboBoxInactive" />
<item android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/ComboBoxActive" />
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/ComboBoxActive" />
<item android:drawable="@drawable/ComboBoxInactive" />
</selector>
what state should I add for when it is displaying the dropdown? I want it to display ComboBoxActive drawable. I already tried adding this:
<item android:state_enabled ="false"
android:drawable="@drawable/ComboBoxActive"/>
Any idea of what the state is?
There is no android:state_dropdown_showing state. The only one state on spinner dropdown list is state_enabled="true"
You can use my selector to differentiate dropdown list state
Don't forget to set setFocusable and setFocusableInTouchMode properties on spinner.
Based on Olef Koshkin answer I can add that if you want save changed state after click to spinner and return it to default only after close spinner you can use. It works for me.
In other cases I see blink of default state and I didn't like it.