Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 450
N.R.S.Sowrabh Avatar asked Oct 30 '12 16:10

N.R.S.Sowrabh


1 Answers

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.

like image 50
aravance Avatar answered Oct 03 '22 08:10

aravance