Collapsing Toolbar and Fragment

后端 未结 1 718
梦谈多话
梦谈多话 2020-12-14 23:03

I have an app that is laid out like this, the mainactivity hosts 2 tabs with accompanied fragments, the first fragment has a recycler view that works, I\'m trying to add the

1条回答
  •  爱一瞬间的悲伤
    2020-12-14 23:24

    You want to set something up like this:

    
    
        
    
        
    
                
    
                
    
            
    
        
    
        
    
            
            
    
        
    
    
    

    This will give you a parallax effect with Fragments inside the ViewPager.

    Make sure you add the:

    android:fitsSystemWindows="true"

    Attribute to both AppBarLayout and CollapsingToolbarLayout, and this attribute to the Toolbar:

    app:layout_collapseMode="pin"

    If you want to add another Fragment you can add a FrameLayout like so:

    
    
        
            
        
    
        
            
            
        
    
        
    
    
    

    0 讨论(0)
提交回复
热议问题