'Full Screen Theme for AppCompat
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();
Solution 1:[1]
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 2:[2]
<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 3:[3]
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 ;)
Solution 4:[4]
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 5:[5]
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 6:[6]
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 7:[7]
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 8:[8]
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 9:[9]
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:
- https://developer.android.com/training/system-ui/immersive#EnableFullscreen
- Full Screen without navigation & status bars
- How to hide the soft-key bar on Android phone?
Note: Using the xml solutions provide in this thread I could only hide the status bar but not the navigation bar.
Solution 10:[10]
requestWindowFeature(Window.FEATURE_NO_TITLE);
Solution 11:[11]
To remove title bar in AppCompat:
@Override
protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
}
Solution 12:[12]
<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 13:[13]
You can try the following :
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowFullscreen">true</item>
</style>
Solution 14:[14]
just this ?
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen">
<item name="android:windowFullscreen">true</item>
</style>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
