导航抽屉状态栏

Navigation Drawer statusbar

我在 导航抽屉 状态栏 时遇到问题。

我正在使用新的设计支持库。在 blogspot 中说:

NavigationView takes care of the scrim protection of the status bar for you, ensuring that your NavigationView interacts with the status bar appropriately on API21+ devices.

但是没有文档,所以我很困惑如何使用抽屉来达到预期的效果。

我尝试在我的 styles-v21 中插入以下属性:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>

在此导航抽屉根据需要工作后但是, 其他活动有透明的状态栏。

谁能给我一个更好的解决方案?

此处最好的解决方案是为 activity 创建特殊主题,并带有这样的导航。

在styles.xml

<style name="NavigationDrawerTheme" parent="AppTheme"/>

但在样式 v21 中,您会将其覆盖为

<style name="NavigationDrawerTheme" parent="AppTheme">
        <item name="android:statusBarColor">@android:color/transparent</item>
</style>

并在 AndroidManifest.xml 中设置

<activity
    android:theme="@style/NavigationDrawerTheme"
    android:name=".activities.MainActivity"
    android:label="@string/title_activity_main" />

所以你在所有活动中都会有正确的行为。 :-)

P.S 如果有人需要更多解释,请发表评论。