Skip to content
Advertisement

Android Activity without ActionBar

I have different Activities in my App and in all of them I do not want the Action Bar. I cannot find how to disable it. I have tried to find an attribute to apply it to the main_activity.xml but so far I did not find anything. Can somebody help me please?

Advertisement

Answer

Haha, I have been stuck at that point a while ago as well, so I am glad I can help you out with a solution, that worked for me at least 🙂

What you want to do is define a new style within values/styles.xml so it looks like this

<resources>
    <style name = "AppTheme" parent = "android:Theme.Holo.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name = "NoActionBar" parent = "@android:style/Theme.Holo.Light">
        <item name = "android:windowActionBar">false</item>
        <item name = "android:windowNoTitle">true</item>
    </style>

</resources>

Only the NoActionBar style is intresting for you. At last you have to set is as your application’s theme in the AndroidManifest.xml so it looks like this

<application
    android:allowBackup = "true"
    android:icon = "@drawable/ic_launcher"
    android:label = "@string/app_name"
    android:theme = "@style/NoActionBar"   <!--This is the important line-->
    >
    <activity
    [...]

I hope this helps, if not, let me know.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement