Android – How to hide toolbar while scrolling listview up? (Just like google play store)


Ok, so hiding the action bar is something doable. But, how can we hide the (newly introduced) toolbar in our activity?

I am making an app with an activity having theme as theme.apcompat.light.noactionbar(to hide the action bar) , I have placed a toolbar with slidingtablayout below it. And below it is my listview.

What I want is to hide the toolbar when I scroll the listview up. But the slidingtablayout should remain there. And while in middle of the listview if I scroll down, the toolbar should again be visible.

Best Solution

Updated (8/24/2015):

Please see my latest answer here using the Design Support Library:

Hiding the ActionBar on RecyclerView/ListView onScroll

Updated (6/2/2015):

ListView + ToolBar - without Libraries:

Please see and

mToolbar = (Toolbar) findViewById(;
mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(;
mNavigationDrawerFragment.setup(, (DrawerLayout) findViewById(, mToolbar);
mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    public void onGlobalLayout() {
        if (Build.VERSION.SDK_INT >= 16) {
        } else {
        mToolbar.animate().translationY(-mToolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();


ListView + ActionBar - without Libraries:

I recently wanted the same functionality and this works perfectly for me:

As the user scrolls upward, the ActionBar will be hidden in order to give the user the entire screen to work work with.

As the user scrolls downward and lets go, the ActionBar will return.


listView.setOnScrollListener(new OnScrollListener() {
    int mLastFirstVisibleItem = 0;

    public void onScrollStateChanged(AbsListView view, int scrollState) {   }           

    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {    
        if (view.getId() == listView.getId()) {
            final int currentFirstVisibleItem = listView.getFirstVisiblePosition();

            if (currentFirstVisibleItem > mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().hide();
            } else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().show();

            mLastFirstVisibleItem = currentFirstVisibleItem;
Related Question