Full Screen Theme for AppCompat

AndroidAndroid ActionbarAndroid Theme

Android Problem Overview


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();

Android Solutions


Solution 1 - Android

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" 
/>

Solution 2 - Android

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" 
/>

Solution 3 - Android

<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.

Solution 4 - Android

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

from [here][1] [1]:https://developer.android.com/training/system-ui/status.html 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 ;)

Solution 5 - Android

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

Solution 6 - Android

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();
}

Solution 7 - Android

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!!

Solution 8 - Android

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>

Solution 9 - Android

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>

Solution 10 - Android

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.

Solution 11 - Android

requestWindowFeature(Window.FEATURE_NO_TITLE);

Solution 12 - Android

To remove title bar in AppCompat:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
    }

Solution 13 - Android

<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>

Solution 14 - Android

You can try the following :

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="android:windowFullscreen">true</item>
</style>

Solution 15 - Android

just this ?

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen">
	<item name="android:windowFullscreen">true</item>
</style>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYe Lin AungView Question on Stackoverflow
Solution 1 - AndroidnebyanView Answer on Stackoverflow
Solution 2 - AndroidHover RuanView Answer on Stackoverflow
Solution 3 - AndroidDharmendra Pratap SinghView Answer on Stackoverflow
Solution 4 - AndroidKrhashisMView Answer on Stackoverflow
Solution 5 - AndroidSimulantView Answer on Stackoverflow
Solution 6 - AndroidShuyan JiView Answer on Stackoverflow
Solution 7 - AndroidJagdishView Answer on Stackoverflow
Solution 8 - AndroidDysaniazzZView Answer on Stackoverflow
Solution 9 - AndroidvntstudyView Answer on Stackoverflow
Solution 10 - AndroidDarushView Answer on Stackoverflow
Solution 11 - AndroidprashantwostiView Answer on Stackoverflow
Solution 12 - AndroidAndoctoreyView Answer on Stackoverflow
Solution 13 - AndroidMatt BarreraView Answer on Stackoverflow
Solution 14 - AndroidSumit ShuklaView Answer on Stackoverflow
Solution 15 - AndroidXanView Answer on Stackoverflow