How to use a TabLayout with Toolbar inside CollapsingToolbarLayout?

后端 未结 18 2316
逝去的感伤
逝去的感伤 2020-11-27 11:46

I am looking at the chrisbanes/cheesesquare and I am trying to put TabLayout with a Toolbar inside a CollapsingToolbarLayout, and here is my code



        
18条回答
  •  悲&欢浪女
    2020-11-27 12:14

    It turns out that since the AppBarLayout extends LinearLayout, you can have two CollapsingToolBarLayouts (extends FrameLayout) in it. What I did was have the first CollapsingToolBarLayout house the contents I wanted to disappear, and gave it the AppBarLayout flag:

    app:layout_scrollFlags="scroll|exitUntilCollapsed"

    For the second CollapsingToolbarLayout that actually had the tabs, I set it's scroll flags to:

    app:layout_scrollFlags="scroll|enterAlways"

    The final XML looks like this and it gives me what I want.

        
    
    
        
    
        
    
            
    
                
    
                    
    
                
    
                
            
    
            
    
                
            
        
    
    

提交回复
热议问题