0

I've been looking for the solution to hide Android Action Bar. Tens of them are published and work the same way - Action Bar is hidden only after it's shown for the second. Not good enough, so I tested more and created my own solution. It was not published anywhere, but seems for me very simple and obvious. The most important is - Action Bar can't be seen at all.

My question is - what's wrong with it ? ) Why did Android dinosaurs avoid something like that ?

Solution to hide Android Action Bar :

in Manifest

 android:theme="@style/CustomActionBarTheme"

in themes.xml

<style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
    parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:layout_marginBottom">-50dp</item>
</style>

As you can see I just use negative marginBottom.

JohnK
  • 264
  • 3
  • 15

4 Answers4

1

You should just use Theme.AppCompat.Light.NoActionBar - it completely removes the action bar as per its name.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
1

Use this parent="Theme.AppCompat.Light.NoActionBar" And allow this in your style

<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>

For More information You may check SO Answer .I hope it will helps you . Full Screen Theme for AppCompat

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

If you don't want to use ActionBar then you have use Theme.AppCompat.Light.NoActionBar Theme.

Apply the following in your Theme for the Activity in AndroidManifest.xml:

<activity android:name=".Activity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

You can hide ActionBar programatically also.

 ActionBar actionBar = getActionBar(); or getSupportActionBar();
 actionBar.hide();

I hope it helps!

Rajesh Jadav
  • 12,801
  • 5
  • 53
  • 78
0

I made it work just changing parent value in /res/values/style.xml:

<resources>
  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  </style>
</resources>

That worked for me.