How to hide ActionBar while scrolling ListView in android?

后端 未结 4 592
南旧
南旧 2020-12-10 01:23

I need to create a GUI with a ListView and an ActionBar which will hide when scrolling down and when scrolling up it must reappear.

The foll

4条回答
  •  有刺的猬
    2020-12-10 01:56

    If you would like to obtain a list with this behaviour, you should:

    • add the design support library with compile 'com.android.support:design:22.2.0'
    • Use a CoordinatorLayout with a Toolbar where you have to define app:layout_scrollFlags="scroll|enterAlways"
    • Use a RecyclerView instead of a ListView. As described here ListView and the GridView have the expected behavior with the CoordinatorLayout only with API>21. In this case you have to use setNestedScrollingEnabled(true);

    The official blog post shows this case:

    
    
         
        
    
        
              
    
    
         
    
    

提交回复
热议问题