Focus Lost Animation on Android / Ice Cream Sandwich

On my tablet, whenever you put your finger on something by clicking (for example, a menu item), it stands out as pale blue. When you push your finger, there is a slight slight fading.

Does anyone know where this animation / color lives in the SDK? I want to programmatically play this animation on the Button that I have.

+4
source share
1 answer

Use the android:exitFadeDuration in the background of the StateListDrawable button:

 <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="100"> <!-- Non focused states --> <item android:drawable="@drawable/button_normal" android:state_focused="false" android:state_pressed="false" android:state_selected="false" /> <item android:drawable="@drawable/button_normal" android:state_focused="false" android:state_pressed="false" android:state_selected="true" /> <!-- Focused states --> <item android:drawable="@drawable/button_focused" android:state_focused="true" android:state_pressed="false" android:state_selected="false" /> <item android:drawable="@drawable/button_focused" android:state_focused="true" android:state_pressed="false" android:state_selected="true" /> <!-- Pressed --> <item android:drawable="@drawable/button_pressed" android:state_pressed="true" /> </selector> 

Please note that this only works for Android> = 3.0 (API level 11)

Docs: http://developer.android.com/reference/android/R.attr.html#exitFadeDuration

+1
source

Source: https://habr.com/ru/post/1402125/


All Articles