JohnK
JohnK

Reputation: 274

Hide Android Action Bar solution

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.

Upvotes: 0

Views: 205

Answers (4)

Roberto Meijide
Roberto Meijide

Reputation: 99

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.

Upvotes: 0

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75778

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

Upvotes: 1

Rajesh Jadav
Rajesh Jadav

Reputation: 12861

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!

Upvotes: 0

ianhanniballake
ianhanniballake

Reputation: 199795

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

Upvotes: 1

Related Questions