简体   繁体   中英

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 ?

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.

    <!--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

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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