Android L's Ripple Effect - Touch Feedback for Buttons - Using XML

前端 未结 7 1679
青春惊慌失措
青春惊慌失措 2020-11-27 11:13

I am trying to understand how to implement the \"Ripple Effect - Touch Feedback\" for buttons and other views. I looked at the questions related to Ripple touch effect on SO

7条回答
  •  误落风尘
    2020-11-27 11:55

    UPDATE Material Components:

    With the Material Components Library it is very easy to apply a ripple.
    Just use the MaterialButton and the app:rippleColor attribute:

    
    

    With a selector like this:

    
    
      
      
      
      
      
    
    
    

    Old answer
    You can do something like this:

    Where the ripple.xml is:

    
            
                
                    
                
            
     
    

提交回复
热议问题