11

i want to hide the top menu bar in my android device & Tablet.Can any one tell me how to do it?Thanks for any help.

joe
  • 221
  • 2
  • 5
  • 13

8 Answers8

9

You can achieve this by setting the android:theme attribute to @android:style/Theme.NoTitleBar on your element in your AndroidManifest.xml like this:

<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>
Jay
  • 1,474
  • 9
  • 13
  • 2
    I tried this but it gave me this gradle build error: "java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity." – Rock Lee Jun 20 '15 at 03:05
  • `android:theme="@style/Theme.AppCompat.NoActionBar"` Worked for me – luckyging3r Aug 07 '20 at 20:40
8

In the Activity class you can use this in onCreate method. In api level greater then 11

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

or

getSupportActionBar().hide();
Muhammad Aamir Ali
  • 20,419
  • 10
  • 66
  • 57
7

For the benefit of searchers, when creating a project in Android Studio, your AndroidManifesst.xml (as shown by @Jay) will reference "AppTheme" as shown below:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
...

If you navigate the folder tree to res/values/styles.xml you can set your style to inherit from a parent style. In my case this did the trick for an application-wide solution.

<resources>

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

</resources>

You can remove the '.light' if you are using a dark theme.

Further reading can be found here.

JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
2

In order to hide the status bar at the bottom of the tab, you can take a look at this library, which I think will help you in your use case. HideBar Library Android. However, this library requires a ROOTed device to work, which I think is the only case you will get it working on devices above versions 4.0.1.

Also, for Android versions < 4, you can try adding the following lines of code in your onCreate() method before setting the layout.

WindowManager.LayoutParams attrs = getWindow().getAttributes(); 
attrs.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN; 
getWindow().setAttributes(attrs); 

or If your application targetSdk is 11 or above (Honeycomb and beyond), you should be using Holo style. So, in your Manifest, use in the <application> tag the attribute:

android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" 

For Android version 2.3.3 and below, you can add this to your application tag from manifest xml: android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" this will make your app run in fullscreen mode.. If you want to have a title bar, just make a custom one and put it into a base activity that all other activities will inherit..

I hope this helps!!!

Shekhar Chikara
  • 3,786
  • 2
  • 29
  • 52
0

If you are trying to hide the navigation bar. then here is the link for the answer Permanently hide navigation bar on activity

Community
  • 1
  • 1
shreyas
  • 2,166
  • 3
  • 18
  • 30
0

Add this

ActionBar actionBar = getActionBar();
    actionBar.hide();
salih
  • 324
  • 1
  • 7
  • 14
0

In your styles.xml add this line of code

<item name="android:windowNoTitle">true</item>

It basically does the same as adding

android:theme="@android:style/Theme.NoTitleBar"

to your Manifest file, but you can keep your own custom styling by adding the line to your styles.xml

Koen van Zuijlen
  • 395
  • 3
  • 11
0

Not show from start is better than show and then hide. You can disable showing of top title ActionBar menu by define NoActionBar theme in your application block main AndroidManifest.xml file:

android:theme="@style/AppTheme.NoActionBar"

Iefimenko Ievgen
  • 379
  • 1
  • 5
  • 12