简体   繁体   English

如何在Android 5.0 Lollipop中更改ActionBar文本颜色?

[英]How to change the ActionBar text color in Android 5.0 Lollipop?

How can I change the text color from the ActionBar in Android Lollipop to white from black ? 如何将Android Lollipop中的ActionBar中的文本颜色更改为黑色中的白色?

This is my current styling. 这是我目前的造型。

<style name="AppCustomTheme" parent="@style/Theme.AppCompat.Light">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">@color/orange_bar</item>
</style>

使用@style/Theme.AppCompat.Light.DarkActionBar来交换文本和许多其他属性的颜色,以更好地适应深色操作栏。

I've read more and manage to find that you need to add this tag in order to change the ActionBar default color in Android Lollipop. 我已经阅读了更多内容并设法发现您需要添加此标记才能更改Android Lollipop中的ActionBar默认颜色。

    <!--textColorPrimary is used to change the text color of the default action bar-->
    <item name="android:textColorPrimary">#FFFFFF</item>

Tested it on 5.0 Lollipop and 4.4 KitKat 5.0 Lollipop4.4 KitKat上测试它

<style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

    <!-- To change action bar text color -->
    <item name="android:textColorPrimary">#123</item>

    <!-- This has to be here to make it work; let me know if you know why -->
    <item name="actionBarTheme">@style/ThemeOverlay.AppCompat.ActionBar</item>        

</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM