Hide TabLayout on Scroll of Content instead of ToolBar

前端 未结 4 758
醉酒成梦
醉酒成梦 2020-12-01 05:24

I want to hide TabLayout on scrolling my content. Currently I searched the net but I found samples which hide the Toolbar, but I want to hide TabLayout. So please help me. I

4条回答
  •  遥遥无期
    2020-12-01 06:05

    While doing animation on scroll, CoordinatorLayout starts searching all the children views of AppBarLayout in a linear manner and it stops animating layouts once it finds a layout with non-scrolling tag.

    Exp1:

    
        
             
             
        
    
    
    Only layout1 will have animation
    

    Exp2:

    
        
             
             
        
    
    
    None of them will have animation
    

    Exp3: If none of them have scrollFlag, none of them will have animation

    Exp4: If both of them have scrollFlag, both of them will have animation


    In your case, you'll need to keep toolbar outside the coordinator layout and add tablayout as a child of AppBarLayout with scrollFlags = "scroll|enterAlway"

提交回复
热议问题