状态栏的颜色不显示 - 5.0棒棒堂的Andr​​oid工作室:(AppCompat-V7:R21) [英] Status Bar Color not showing - 5.0 Lollipop Android Studio: (AppCompat-v7:r21)

查看:155
本文介绍了状态栏的颜色不显示 - 5.0棒棒堂的Andr​​oid工作室:(AppCompat-V7:R21)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 AppCompat-V7:为Android 5.0棒棒堂在Android的工作室21.0.0 支持库。我的问题是,可以通过在值/ styles.xml 文件中设置 colorPrimaryDark 更改状态栏的颜色,被显示为黑色,在XML布局preVIEW和仿真器两种。

I'm using the AppCompat-v7:21.0.0 support library for Android 5.0 Lollipop in Android Studio. My problem is that the Status Bar Color that can be changed by setting colorPrimaryDark in the values/styles.xml file, is showing up as black, in both the xml layout preview and the emulator.

那么,什么是错的?我失去了一些东西?请告诉我。谢谢你。

So what's wrong? Am I missing something? Please let me know. Thanks.

编辑: 我是知道的事实,改变的pre-棒棒糖版本的状态栏的颜色是不可能的。我的XML布局编辑器preVIEW和我的仿真器均设置为API等级21(5.0棒棒堂)。但是,状态栏仍是我在 colorPrimaryDark 设置它的颜色不会。我试着在 styles.xml ,但无济于事做 statusBarColor 。它仍然是黑色的。

I'm aware of the fact that changing the status bar color on Pre-Lollipop versions is not possible. My XML Layout Editor Preview and my Emulator are both set to API Level 21 (5.0 Lollipop). But, the status bar still isn't of the color I set it to in colorPrimaryDark. I tried doing statusBarColor in styles.xml but to no avail. It's still black.

同时: 我看到一个类似的问题的答案之一,他们劝我把我的的minSdkVersion 来21.我试过了,但没有奏效。我希望我的应用程序与API级别的设备上运行15以上。

ALSO: I saw one of the answers on a similar question where they advised me to put my minSdkVersion to 21. I tried that, but it didn't work. And I want my app to run on devices with API Level 15 and above.

推荐答案

请阅读本:对于此生效,该窗口必须是图纸系统栏背景与

Please read this: For this to take effect, the window must be drawing the system bar backgrounds with

android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS

android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS

不能设置(<一个href="http://developer.android.com/reference/android/view/Window.html#setStatusBarColor(int)">Source)

如果你不知道如何添加标记:

In case of you don't know how to add that flag:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

这篇关于状态栏的颜色不显示 - 5.0棒棒堂的Andr​​oid工作室:(AppCompat-V7:R21)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆