【问题标题】:use all the space in android full screen mode在android全屏模式下使用所有空间
【发布时间】:2018-06-04 04:51:03
【问题描述】:

在android studio中,当我设置全屏模式时,我仍然无法使用屏幕中的所有空间(例如导航栏的空间)。

我该怎么办?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
tools:context=".Game">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/start_game"
    android:textColor="@color/white" />

第 4 行和第 5 行中的匹配父级不考虑全屏模式。

这就是我让它全屏的方式:

        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION);

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    您应该在 AndroidManifest.xml 文件中更改主题。

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.example.project" >
    
            <application
                    android:allowBackup="true"
                    android:icon="@drawable/ic_launcher"
                    android:label="@string/app_name"
                    android:theme="@style/AppTheme" >
                    <activity
                            ...
                            android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
                            ...
                    </activity>
            </application>
    
    </manifest>
    

    或将@style/AppTheme 更改为全屏模式。

    【讨论】:

      【解决方案2】:

      你可以在java文件中做到这一点:

      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // remove title
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
          setContentView(R.layout.main);
      }
      

      您也可以通过AndroidMenifest

      <activity android:name=".ActivityName"
          android:label="@string/app_name"
          android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-29
        相关资源
        最近更新 更多