Search code examples
javaandroidandroid-actionbar

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?


Solution

  • 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
        [...]