SupaGu
SupaGu

Reputation: 621

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.

Upvotes: 8

Views: 3320

Answers (2)

Matthias Robbers
Matthias Robbers

Reputation: 15728

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.

Upvotes: 5

Sherlock Yiu
Sherlock Yiu

Reputation: 123

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

Upvotes: 2

Related Questions