Hide Actiobar smoothly on Listview scroll up
I want to hide the action bar if I scroll through the list. It should look like the new Play Store app on Android Lollipop. If I use getActionBar (). Hide () the action bar is hiding the animation, but I want to scroll the Actiobar to the top.
How it works?
Edit
I found that ActionBar can auto-hide in API level 21:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.activity_main);
m_lvTest = (ListView)findViewById(R.id.lvTest);
ArrayList<String> values = new ArrayList<String>();
for (int i = 0; i < 100; i++) {
values.add(i+" Item");
}
CustomAdapter adapter = new CustomAdapter(this, R.id.lvTest, values);
m_lvTest.setAdapter(adapter);
m_lvTest.setNestedScrollingEnabled(true);
getActionBar().setHideOnContentScrollEnabled(true);
}
But it doesn't scroll. He animates.
source to share
There is a method called setHideOnContentScrollEnabled (boolean) ' ActionBar . Enable hiding the action bar in scrolling content. If enabled, the action bar scrolls out of the field of view, along with the nested scrollable content of the child view. The action bar must be in overlay mode to hide scrolling content. When the screen is partially scrolled, the action bar is hidden. Calling to show will cause it to go back to full view. I think you can try it with your own codes.