Animate change of view background color on Android

前端 未结 16 743
孤街浪徒
孤街浪徒 2020-11-22 13:23

How do you animate the change of background color of a view on Android?

For example:

I have a view with a red background color. The background color of the

16条回答
  •  忘了有多久
    2020-11-22 14:09

    The documentation on XML powered animations is horrible. I've searched around hours just to animate the background color of a button when pressing... The sad thing is that the animation is only one attribute away: You can use exitFadeDuration in the selector:

    
    
        
            
        
    
        
            
        
    
    
    

    Then just use it as background for your view. No Java/Kotlin code needed.

提交回复
热议问题