繁体   English   中英

更改操作栏标题颜色Theme.AppCompat.Light.DarkActionBar android

[英]change action bar title color Theme.AppCompat.Light.DarkActionBar android

我想在android中将操作栏标题颜色更改为白色。 我在值Theme.AppCompat.Light和values-14使用主题Theme.AppCompat.Light.DarkActionBar
到目前为止我在values文件夹中尝试过:

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:textColor">@android:color/white</item>
</style>

和值-14文件夹

  <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:textColor">@android:color/white</item>
</style>

但ActionBar标题颜色没有变化。

您可以使用colorPrimary属性指定ActionBar的背景颜色; 类似以下内容:

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@android:color/white</item>
    </style>

以上是为AppCompat创建的特殊标记; 你会注意到android: namespace被省略了。

如果您使用的是Theme.AppCompat.Light.NoActionBar

<android.support.v7.widget.Toolbar  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="@color/background_material_dark"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

你还应该检查你在布局xml文件中没有指定一个android:theme属性,它将优先于主题

暂无
暂无

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

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