How to make sticky section headers (like iOS) in Android?

后端 未结 5 1905
死守一世寂寞
死守一世寂寞 2020-12-23 14:25

My specific question is: How I can achieve an effect like this: http://youtu.be/EJm7subFbQI

The bounce effect is not important, but i need the \"sticky\" effect for

5条回答
  •  死守一世寂寞
    2020-12-23 14:36

    Add this in your app.gradle file

    compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
    

    then my layout, where I have added android:tag ="sticky" to specific views like textview or edittext not LinearLayout, looks like this. It also uses databinding, ignore that.

        
    
    
        
    
            
    
            
        
    
        
    
    
            
                
                
    
    
                    
    
                        
    
    
                            
    
                            
    
                                
    
                            
    
                            
    
                                
    
                            
    
                            
    
                                
    
                            
    
                            
    
                                
    
                            
    
    
                        
                    
    
                    
    
                        
    
    
                    
    
                    
    
                        
    
    
                    
    
    
    
                
            
    
    
        
    
    

    style group for the textview looks this

     
    

    and the background for the textview goes like this:(@drawable/businessdetailtitletextviewbackground)

    
    
        
            
                
            
        
        
            
                
            
        
    
    

提交回复
热议问题