vxh.viet
4/1/2016 - 2:58 AM

Remove ActionBar

Remove ActionBar

Source: StackOverflow

Question: I would like to know how can I apply full screen theme ( no title bar + no actionbar ) to an activity. I am using AppCompat library from support package v7.

Answer: When you use Theme.AppCompat in your application you can use FullScreenTheme by adding the code below to styles.xml.

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
</style>

And in the AndroidManifest.xml, reference it under <application> tag to have app wide effect (or under specific activity):

<application
    android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">

Bonus: Doing this to get Fullscreen with title bar:

<style name="Theme.AppCompat.Light.NoActionBar.WithTitle" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
</style>

YES, I UNDERSTAND windowNoTitle = true and you get title bar? WTF did you SMOKE? IT DOESN"T MAKE SENSE BUT IT WORKS, SO TRUST ME OK?