Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: ActionBar like the stock browser

I want my ActionBar to act like it does in the stock/default Android browser: It visible at the top of the page, but as the user scrolls down, the bar scrolls out of view, how ever if you scroll the page upward towards the top, the bar comes in to view again, but will hide after some time out, when it does this, it does not affect the underlying view.

I've tried implementing auto-hiding using timers but when the ActionBar hides, it moves up the scrollable view underneath so it looks as is my whole page shifts up instead of the ActionBar floating over the top of the view.

like image 992
SupaGu Avatar asked Jan 12 '13 05:01

SupaGu


2 Answers

You are looking for the action bar overlay mode in combination with the Quick Return pattern. That is the feature, where a view becomes visible on top again when the user scrolls up a little. See this excellent blog post describing this pattern. Don't miss the example implementation by Roman Nurik from Google.

Enable the overlay mode by requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY) before setContentView() or by setting the theme attribute android:windowActionBarOverlay to true.

like image 60
Matthias Robbers Avatar answered Oct 23 '22 15:10

Matthias Robbers


Did you try the overlay mode on the ActionBar, getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY)?
Then add a marginTop to your main layout.

like image 2
Sherlock Yiu Avatar answered Oct 23 '22 17:10

Sherlock Yiu