N.R.S.Sowrabh
N.R.S.Sowrabh

Reputation: 725

Set Actionbar overlay mode at runtime in Android

How do I set the actionbar mode at runtime to not-overlay or overlay with the content at runtime? I tried using getWindow().requestFeature(Window.FEATURE_ACTIONBAR_OVERLAY) but it doesn't allow to set the mode after calling setContentView(). This can be done, as I have seen it being done in the Youtube app.

Upvotes: 14

Views: 6180

Answers (1)

aravance
aravance

Reputation: 89

Although not necessarily exactly what you're looking for, one decent workaround would be to create a spacer view at the top of the content that is the same height as the ActionBar (android:layout_height="?android:actionBarSize"). When you want overlay mode enabled, set the spacer's visibility to View.GONE, when you want it disabled, set it to View.VISIBLE.

Upvotes: 5

Related Questions