Android ActionBar hide/show when scrolling list view

后端 未结 4 1037
感动是毒
感动是毒 2020-12-09 04:53

I want to hide/show the compatibility action bar as the user scrolls up/down a listview. When the action bar disappears the list will occupy also the action bar\'s space.

相关标签:
4条回答
  • 2020-12-09 05:24

    you could try this library. Hope it helps https://github.com/ksoichiro/Android-ObservableScrollView

    0 讨论(0)
  • 2020-12-09 05:24

    See my answer on that link: How to hide and show the Android ActionBar like in Google Inbox app? I am using RecyclerView but the idea is the same

    0 讨论(0)
  • 2020-12-09 05:40

    To avoid the flickering caused by the readjustment of the layout you can use the overlaying property in the action bar.

    https://developer.android.com/training/basics/actionbar/overlaying.html

    But this solution causes that the action bar overlays your listview, so you need to add a header with this size:

    "?android:attr/actionBarSize"

    for example :

    mVideosListView = (ListView) getActivity().findViewById(android.R.id.list);
    mVideosListView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.listview_header,null));
    

    Be careful with other elements like navigation drawer which is also affected by this.

    0 讨论(0)
  • 2020-12-09 05:46

    You need to make the action bar overlays the listview. By doing this you have the responsibility to manage of hiding and showing the action bar when necessary.

    There is an example at the following page: http://www.techrepublic.com/article/pro-tip-maximize-android-screen-real-estate-by-showing-and-hiding-the-action-bar/

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