This is what I need:
A selector to show that you pressed it. But this selector also handles the long-press color transition. I looked a lot and found this. This is basically what I need, but this only works with images, not colors. Here is my code right now:
default_selector.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android:color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@android:color/transparent" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@android:color/transparent" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/default_selector_transition" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/default_selector_transition" />
<item android:state_focused="true" android:drawable="@color/selection_grey" />
<item android:state_activated="true" android:drawable="@color/selection_grey"/>
<item android:drawable="@android:color/transparent" />
</selector>
default_selector_transition.xml:
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/list_pressed_default" />
<item android:drawable="@drawable/list_longpressed_default" />
</transition>
The drawables in default_selector_transition.xml are now 9 patches. I want to know if it is possible to change this to colors.
What I tried:
- Just put a color instead of a drawable in there
- Put a color as drawable in there (
<drawable name="selection_grey_drawable">#BDBDBD</drawable>
)
I'm hoping you guys have a solution for me!