Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the bottom action bar in Android?

I set "android:uiOptions="splitActionBarWhenNarrow" in AndroidManifest.xml. Therefore, if there is no enough room for the device, the action bar will be split into two parts.

Sometime, I want to hide the action bar by calling getActionBar().hide(). But it will leave an ugly white space in the bottom. How can I get rid of it?

I tried to call getActivity().getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY), but it would block my webview content.

Before

After

like image 431
Dragon warrior Avatar asked Oct 20 '22 18:10

Dragon warrior


1 Answers

Just a simple work, simply use OverLay. use this in your style

<style name="AppTheme" parent="@style/Theme.AppCompat">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowActionBarOverlay">true</item>
</style>

or if you want to do it by programmatically, just past it before your setContentView() function

requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

and give some transparency, so it won't hide the web content. just read the documentation for the style

http://developer.android.com/training/basics/actionbar/overlaying.html

like image 97
Kirk Avatar answered Oct 29 '22 02:10

Kirk