32

I need my app to show as full screen. Now I know how to add this feature into the application tag in Mainfest using

android:theme=”@android:style/Theme.NoTitleBar.Fullscreen"

However, I have my own theme called "CodeFont", and I cannot use two themes in the same application. How I can add this feature into my own style tag in my resources file? There is no such things as an android:style tag.

5 Answers 5

73

Create your custom theme by using default theme, like this

window with Fullscreen

<style name="generalnotitle" parent="general">
    <item name="android:windowFullscreen">true</item>
</style>

window with NoTitle

<style name="generalnotitle" parent="general">
    <item name="android:windowNoTitle">true</item>
</style>
3
  • 2
    this does not do fullscreen. you need <item name="android:windowFullscreen">true</item>
    – robsf
    Dec 7, 2012 at 20:18
  • 7
    In case someone wonders, put this on res/values/styles.xml.
    – v42
    Dec 13, 2013 at 19:06
  • When I do this with windowFullscreen set to false, it does the opposite of what I expect it to. It makes my dialog go completely fullscreen. Whereas without the custom theme, my dialog is just huge, taking up practically the entire screen (both width and height) uneccessarily. Why is that?
    – RTF
    Feb 24, 2014 at 23:29
11

Create your custom theme with parent attribute to inherit NoTitleBar.Fullscreen property from general android theme.

values/styles.xml

<resources> 
   <style name="CodeFont" parent="android:Theme.NoTitleBar.Fullscreen">
      <item name="android:windowNoTitle">true</item> 
      ...
   </style>
</resources>

AndroidManifest.xml

<activity 
    android:name=".MainActivity" 
    android:theme="@style/CodeFont"> 
      ...
</activity>
6

in style.xml add

<item name="android:windowFullscreen">true</item>

to your theme. Example:

<style name="CodeFont" parent="android:Theme.Light">
     <item name="android:windowFullscreen">true</item>
</style>
1

you can request some features and flags in code by using ( for example ):

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.some_layout);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
0

Setting up a theme in app styles works for my React Native application. Just type in the android/app/src/main/res/values/styles.xml:

<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen"></style>
</resources>

And in the android/app/src/main/AndroidManifest.xml link to this theme:

<application
  ...
  android:theme="@style/AppTheme">

Reference

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.