fitsSystemWindows没有使状态栏透明

Gui*_*ira 5 android

我有一个ConstraintLayout,我想在其中包含折叠工具栏布局.所以,我遵循了这个教程:https://antonioleiva.com/collapsing-toolbar-layout/

但是,即使在我的XML中的几乎每个组件中包含fitsSystemWindows之后,我的状态栏也不透明.

这是我在活动中使用的风格

<style name="AppTheme2" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

XML布局太大了,所以我把它放在这个要点上:https://gist.github.com/guuilp/6e20ff9e00af8b85c858c5e832a17c34

此外,后退按钮也未显示.

Dre*_*rko 7

将以下内容添加到您的主题中,请注意这需要minSdkVersion为19.

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
Run Code Online (Sandbox Code Playgroud)

然后android:fitsSystemWindows=”true”在活动中设置透明状态栏.