【问题标题】:Navigation Drawer statusbar导航抽屉状态栏
【发布时间】:2015-07-12 15:08:56
【问题描述】:

我无法通过状态栏制作导航抽屉

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

NavigationView 负责状态栏的 scrim 保护 为您,确保您的 NavigationView 与状态交互 栏在 API21+ 设备上适当。

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

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

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

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

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

【问题讨论】:

  • 发布您的布局和样式。
  • 感谢 gabriele 的回复,我找到了答案,我会回答并关闭问题!

标签: android navigation-drawer android-design-library androiddesignsupport


【解决方案1】:

这里最好的解决方案是为带有这样导航的活动创建特殊主题。

在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" />

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

附言 如果有人需要更多解释,请发表评论。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-30
    • 2014-12-27
    • 1970-01-01
    • 1970-01-01
    • 2017-05-28
    • 1970-01-01
    • 2015-01-10
    相关资源
    最近更新 更多