enableEdgeToEdge - 导航系统栏不完全透明

问题描述 投票:0回答:1

为什么导航系统不完全透明?

enableEdgeToEdge(
    statusBarStyle = SystemBarStyle.auto(
        Color.TRANSPARENT,
        Color.TRANSPARENT,
    ) { false },
    navigationBarStyle = SystemBarStyle.auto(
        lightScrim,
        darkScrim,
    ) { false },
)

setContent {
    ArchApp()
}

我使用官方android示例的代码https://github.com/android/nowinandroid/blob/main/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt#L123

主题(与nowinandroid中相同)

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

    <!-- Allows us to override night specific attributes in the
         values-night folder. -->
    <style name="NightAdjusted.Theme.App" parent="android:Theme.Material.Light.NoActionBar" />

    <!-- The final theme we use -->
    <style name="Theme.App" parent="NightAdjusted.Theme.App" />

    <style name="NightAdjusted.Theme.Splash" parent="Theme.SplashScreen">
        <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
        <item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
    </style>

    <style name="Theme.App.Splash" parent="NightAdjusted.Theme.Splash">
        <item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash_logo</item>
        <item name="windowSplashScreenBackground">@color/splash_screen_background</item>
        <item name="postSplashScreenTheme">@style/Theme.App</item>
    </style>
</resources>

主题之夜(与nowinandroid中相同)

<style name="NightAdjusted.Theme.App" parent="android:Theme.Material.NoActionBar" />

<style name="NightAdjusted.Theme.Splash" parent="Theme.SplashScreen">
    <item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
    <item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>

在nowinandroid应用程序中完全透明

android android-navigation android-compose
1个回答
0
投票

使用以下内容:

enableEdgeToEdge(
        statusBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT),
        navigationBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT) // light causes internally enforce the navigation bar to be fully transparent
    )

.light
看一下,如果您深入实施,您会发现它会影响
window.isNavigationBarContrastEnforced
,从而使其变得完全透明

© www.soinside.com 2019 - 2024. All rights reserved.