导航抽屉状态栏 [英] Navigation Drawer statusbar
问题描述
我无法在状态栏上制作导航抽屉.
我正在使用新的设计支持库.在博客里说:
I'm using new Design support library. In blogspot thay said:
NavigationView负责状态栏的稀松布保护 为您服务,确保您的NavigationView与状态交互 在API21 +设备上正确设置.
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.
但是它没有文档,所以我很困惑如何使用Drawer来达到预期的效果.
我尝试在styles-v21中插入以下属性:
I tried inserting following attributes in my styles-v21:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
此导航抽屉根据需要工作后但, 其他活动具有透明的状态栏.
after this Navigation drawer is working as needed but, other activities have transparent statusbar.
有人可以给我一个更好的解决方案吗?
Can somebody give me a better solution?
推荐答案
这里最好的解决方案是为具有导航功能的活动创建特殊主题.
The best solution here is to create special theme for activity with navigation like this.
在styles.xml中
in styles.xml
<style name="NavigationDrawerTheme" parent="AppTheme"/>
但是在样式v21中,您将其替换为
but in styles v21 you will override this as
<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" />
因此,您将在所有活动中都具有正确的行为. :-)
So you will have correct behavior in all activities. :-)
P.S 如果有人需要更多说明,请发表评论.
P.S If someone needs more explanation, comment.
这篇关于导航抽屉状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!