当primaryDark为白色时更改状态栏文本颜色 [英] Change status bar text color when primaryDark is white
问题描述
我正在尝试重现Google日历应用程序的行为:
I am trying to reproduce the behaviour of Google Calendar application:
但我没有找到一种更改状态文本颜色的方法。如果我将colorPrimaryDark设置为白色,则状态栏也不会显示图标,因为它们的颜色也是白色。
but I have not found a way to change the status text color. If i set the colorPrimaryDark as white I cannot see the icons neither text of status bar due their color is white as well.
是否可以更改状态栏文本
Is there any way to change the status bar text color?
预先感谢
推荐答案
我不确定您要定位的API级别,但是如果可以使用API 23特定的东西,则可以将以下内容添加到AppTheme styles.xml中:
I'm not sure what API level your trying to target, but if you can use API 23 specific stuff, you can add the following to your AppTheme styles.xml:
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
<item name="android:windowLightStatusBar">true</item>
,状态栏颜色为白色时,状态栏文本颜色将为可见,而 android:windowLightStatusBar
设置为false时,状态栏文本颜色为
when android:windowLightStatusBar
is set to true, status bar text color will be able to be seen when the status bar color is white, and vice-versa
when android:windowLightStatusBar
is set to false, status bar text color will be designed to be seen when the status bar color is dark.
例如:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- Status bar stuff. -->
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
<item name="android:windowLightStatusBar">true</item>
</style>
这篇关于当primaryDark为白色时更改状态栏文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!