using a custom color for button background while using selectableItemBackground attribute

后端 未结 6 2175
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 21:37

I am trying to use

android:background=\"?android:attr/selectableItemBackground\"

to get my button to do appropriate effects for each android versi

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 22:20

    Using this method, you can customize ripple effect color. First, you have to create an xml file in your drawable resource directory. Create a ripple_effect.xml file and add following code. I use background colour as Red.

    res/drawable/ripple_effect.xml

    
    
        
            
                
            
        
    
    

    And set background to above drawable resource file. Final code of xml layout activity looks like this. res/layout/ripple_animation.xml

    
    
    
    
    
        
            
                
                
            
            
                
                
    
                
                
                
    
            
        
    
        
    

    Now,ripple effect is Red colour.

提交回复
热议问题