330

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.

I've tried to applied android:theme="@android:style/Theme.NoTitleBar.Fullscreen" to my specific activity but it crashed. I think it's because my application theme is like this.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

I also have tried this

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

which only hides title bar but not the action bar. My current workaround is that hiding the actionbar with

getSupportActionBar().hide();
Kuffs
  • 35,581
  • 10
  • 79
  • 92
Ye Lin Aung
  • 11,234
  • 8
  • 45
  • 51

15 Answers15

888

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

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

and also mention in your manifest file.

<activity
   android:name=".activities.FullViewActivity"
   android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" 
/>
Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66
nebyan
  • 9,347
  • 1
  • 20
  • 20
  • 67
    The parent style should be "Theme.AppCompat.Light.NoActionBar" – Hover Ruan Jan 24 '15 at 12:50
  • 4
    Actually, it's enough to add this to the style xml file: true. The action bar (title bar) visibility can be separately controlled using .hide/.show methods at runtime. – Amin Mar 14 '16 at 09:06
  • 2
    FEATURE_NO_TITLE was not being honored. Dunno the difference, but I finally changed my Activity to extend Activity instead of AppCompatActivity and my same code worked (thankfully I don't need AppCompat): this.requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); – user888867 Nov 18 '16 at 05:00
  • this hides status bar as well :( – Omama Nov 28 '16 at 06:53
  • 4
    I would add `hideNavigation()` in `onResume()` - without that, the navigation bar was still visible in my app (api 18+) – Antek Jul 10 '17 at 09:17
  • no need to set `true false` if your theme includes `.NoActionBar` – user924 Dec 02 '18 at 16:09
  • Is there a list anywhere of all of the Theme.AppCompat variants? – Edward Falk Sep 18 '20 at 23:07
  • I had to replace "android:windowNoTitle" with "windowNoTitle" for this to work. – nayakasu Nov 23 '22 at 10:05
74

Based on the answer by @nebyan, I found that the action bar is still not hiding.

The following code works for me:

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

and of course dont forgot to edit your AndroidManifest file.

<activity
    android:name="YOUR_ACTIVITY_NAME"
    android:theme="@style/AppFullScreenTheme" 
/>
Kopi Bryant
  • 1,300
  • 1
  • 15
  • 30
Hover Ruan
  • 3,415
  • 2
  • 19
  • 12
19
<style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

Using the above xml in style.xml, you will be able to hide the title as well as action bar.

Dharmendra Pratap Singh
  • 1,332
  • 1
  • 11
  • 22
13

Issues arise among before and after versions of Android 4.0 (API level 14).

from here I created my own solution.

@SuppressLint("NewApi")
@Override
protected void onResume()
{
    super.onResume();

    if (Build.VERSION.SDK_INT < 16)
    {
        // Hide the status bar
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Hide the action bar
        getSupportActionBar().hide();
    }
    else
    {
        // Hide the status bar
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        / Hide the action bar
        getActionBar().hide();
    }
}

I write this code in onResume() method because if you exit from your app and then you reopen it, the action bar remains active! (and so this fix the problem)

I hope it was helpful ;)

ॐ Rakesh Kumar
  • 1,318
  • 1
  • 14
  • 24
KrhashisM
  • 133
  • 1
  • 4
  • Notice that if user manually pull the status bar, it won't rehide itself. To make it worse, if soft keyboard is showing, status bar automatically shows as well and again, won't rehide. – Hendra Anggrian Apr 11 '17 at 16:04
7

Your "workaround" (hiding the actionBar yourself) is the normal way. But google recommands to always hide the ActionBar when the TitleBar is hidden. Have a look here: https://developer.android.com/training/system-ui/status.html

Simulant
  • 19,190
  • 8
  • 63
  • 98
7

You can follow below step:-

AndoridMenifest.xml

<activity
            android:name=".ui.FullImageActivity"
            android:label="@string/title_activity_main"
            android:screenOrientation="landscape"
            android:theme="@style/DialogTheme">
        </activity>

Style.xml

<style name="DialogTheme" parent="android:Theme.Dialog">

    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">fill_parent</item>

   <!-- No backgrounds, titles or window float -->
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowIsFloating">false</item>
</style>

FullImageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    setContentView(R.layout.image_view);
     }

I hope it will help..Thanks!!

Jagdish
  • 2,418
  • 4
  • 25
  • 51
7
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //to remove "information bar" above the action bar
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //to remove the action bar (title bar)
    getSupportActionBar().hide();
}
Shuyan Ji
  • 121
  • 2
  • 3
5

To hide both status bar and action bar and make your activity full-screen use the following code in your activity's onResume() or onWindowFocusChanged() method:

@Override
protected void onResume() {
    super.onResume();
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN);
}

You can find more Information in the following links:

Note: Using the xml solutions provide in this thread I could only hide the status bar but not the navigation bar.

Darush
  • 11,403
  • 9
  • 62
  • 60
4

This theme only works after API 21(included). And make both the StatusBar and NavigationBar transparent.

<style name="TransparentAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="windowActionBar">false</item>
  <item name="windowNoTitle">true</item>
  <item name="android:statusBarColor">@android:color/transparent</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:navigationBarColor">@android:color/transparent</item>
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowContentOverlay">@null</item>
</style>
DysaniazzZ
  • 825
  • 15
  • 29
4

It should be parent="@style/Theme.AppCompat.Light.NoActionBar"

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" 
parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>
vntstudy
  • 2,038
  • 20
  • 24
  • Only this solution actually hides the title bar and makes it completely full screen. Should be marked as the correct solution. Thanks! – Darko Maksimovic Jun 24 '19 at 01:26
2
requestWindowFeature(Window.FEATURE_NO_TITLE);
prashantwosti
  • 980
  • 2
  • 7
  • 17
2

You can try the following :

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="android:windowFullscreen">true</item>
</style>
Sumit Shukla
  • 4,116
  • 5
  • 38
  • 57
1

To remove title bar in AppCompat:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
    }
Andoctorey
  • 728
  • 9
  • 11
1
<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>

Matt Barrera
  • 149
  • 1
  • 8
  • 1
    Please also explain code, if you provide it, it helps understanding your code and may help to gain insights for future problems. – Lepidopteron May 15 '17 at 13:07
0

just this ?

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen">
    <item name="android:windowFullscreen">true</item>
</style>
Alessandro Scarozza
  • 4,273
  • 6
  • 31
  • 39