Android-L CardView Visual Touch Feedback

后端 未结 4 490
故里飘歌
故里飘歌 2020-11-28 19:49

could anybody explain to me how to implement some of the visual touch feedback that was demonstrated at Google I/O 2014 within a CardView.

Here is how I am using the

4条回答
  •  醉话见心
    2020-11-28 20:27

    To draw selection on pre-Lollipop and post-Lollipop correctly you can use the following approach (the idea is to use inset drawable of selector with rounded corners for pre-Lollipop - sample below uses custom colors, you can change them to default):

    android:foreground="@drawable/card_foreground"
    

    post-Lollipop

    drawable-v21/card_foreground.xml

    
    

    drawable-v21/card_foreground_selector.xml

    
        
            
                
            
        
        
            
                
            
        
    
    

    pre-Lollipop

    drawable/card_foreground.xml (you'll need to tweak inset values according to elevation of your card)

    
    

    drawable/card_foreground_selector.xml

    
        
            
                
                
            
        
        
            
                
                
            
        
    
    

提交回复
热议问题