首页 > 解决方案 > 隐藏导航时沉浸式模式留下略透明的白条

问题描述

进入全屏沉浸模式时,导航栏所在的部分较亮

这是我的 XML 布局文件:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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"
    tools:context=".activities.QuoteActivity">

    <TextView
        android:id="@+id/quote"
        android:layout_width="320dp"
        android:layout_height="wrap_content"
        android:fontFamily="@font/din_light"
        android:gravity="center_horizontal"
        android:text="&quot;Quote&quot;"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/quote_author"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:fontFamily="@font/din_light"
        android:gravity="center_horizontal"
        android:text="- Author"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/quote" />
</androidx.constraintlayout.widget.ConstraintLayout>

这些是我用来进入沉浸式模式的标志:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quote);
    this.getWindow().getDecorView().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);
}

这是我的styles.xml:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowBackground">@drawable/bg_2880x1440</item>

    </style>

    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:background">@drawable/ls_2880x1440</item>
    </style>
</resources>

我没有 android:fitsSystemWindows="true" 在我的程序中使用任何地方。

白色条带不是我背景的一部分。

当我截图它时,它就消失了(图像是它在应用程序中的样子)

这也发生在顶部,但不太明显。

所以我的问题是,我该如何摆脱这个?

标签: javaandroidxml

解决方案


推荐阅读