I have a very simple selector that I use as the background for some buttons to achieve states. Here is the xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@color/home_button_blue_down" android:state_selected="true" />
<item android:drawable="@color/home_button_blue_down" android:state_pressed="true" />
<item android:drawable="@color/home_button_blue" />
</selector>
With this selector, a fade animation will appear every time the button changes. In other words, the transition will come to life both during the transition from depression and when pressed, as well as when returning from the pressed to the pressed.
Now, my question is: is it possible to make only one of these state changes animate? When the user clicks the button, I want the down-down transition to happen immediately without animation. When the button is pressed, I want the downstream device to disappear when the normal state fades. Can this be done?
source
share