How to set XML fullscreen in Android

后端 未结 2 1822
心在旅途
心在旅途 2021-01-01 16:54

How do I create a full screen mode in XML irregardless of how small what contents are in it?

Here\'s my \"show.xml\" code:



        
相关标签:
2条回答
  • 2021-01-01 17:11

    As the other answer doesn't work for me:


    <style name="AppTheme.Fullscreen">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
    </style>
    

    Add this style to your styles.xml


    <activity
        android:name=".TitlesActivity"
        android:theme="@style/AppTheme.Fullscreen">
    

    Make sure your activity in the AndroidManifest.xml refers to your theme.

    0 讨论(0)
  • 2021-01-01 17:32

    Afaik you can't do fullscreen in xml. You have two choices:

    1. AndroidManifest.xml in activity's section
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
    
    1. in onCreate() before calling setContentView
    requestWindowFeature( Window.FEATURE_NO_TITLE );
    
    getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN,
                          WindowManager.LayoutParams.FLAG_FULLSCREEN );
    
    0 讨论(0)
提交回复
热议问题