I'm using appCompat action bar. I'm try to make a home feed like instagram while the user scroll down the action bar is hide and vice versa.
The code below is the most basic way to hide and show a action while scrolling the list view
int mLastFirstVisibleItem = 0;
if (view.getId() == mListView.getId()) {
final int currentFirstVisibleItem = mListView.getFirstVisiblePosition();
if (currentFirstVisibleItem > mLastFirstVisibleItem) {
getSupportActionBar().hide();
} else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
getSupportActionBar().show();
}
mLastFirstVisibleItem = currentFirstVisibleItem;
}
The problem is while I scroll the listview slowly the action bar will keep hide and show repeatly.It does not give me the ability to control how much I want hide or show the action bar. What I want is when I scroll down or up the list view the action bar will follow the gesture eventually when the user hand off from the screen it will hide or show depend on the size of remain visible action bar on the screen.
For instance while I scrolling down 2px the action bar will going up or hide 2px. And if the action bar size remain on the screen is 20px while the action bar size is 50px it will hide it like the code below.
//this is just a demo of how I want the action bar to work not any type of programming language
//visibleActionBarOnscreen is the actionbarsize remain on screen
if(visibleActionBarOnScreen > actiobarSize/2){
//show the action bar
}else{
//hide the action bar
}
Push out/pull in ActionBar when ListView is scrolled this link teaches how control the action bar. But I still dont know how to make it done.In additional it doesn't auto readjust the action bar to either fully hide or show but let the action bar appear half on screen while the user hand off from the screen. Please help me done this I will be 100% apperciate!