【问题标题】:Change ActionBar text color using AppCompat使用 AppCompat 更改 ActionBar 文本颜色
【发布时间】:2017-07-08 15:39:40
【问题描述】:

我正在尝试像这样更改 ActionBar 文本颜色。

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>


<style name="MyTheme.ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
</style>

根据很多similar topics (another one) 这应该可以工作,但是这些都不会改变文本颜色,而且当我尝试这个时,我的 ActionBar 变得透明。我可以通过改变 AppTheme 中的 textColorPrimary 来改变它的文本颜色,但它也改变了很多东西。

我还想查看任何有关样式在 android 中的工作原理的链接,它的层次结构让我有点困惑

【问题讨论】:

    标签: android xml android-actionbar styles


    【解决方案1】:

    你为什么不用ToolBar这样的xml

     <android.support.v7.widget.Toolbar
                android:id="@+id/videos_toolbar"
                style="@style/ToolBarTextStyle"
                android:layout_width="match_parent"
                android:layout_height="?android:actionBarSize"
                android:layout_alignParentTop="true"
                android:background="@color/ToolBarColor"
                android:paddingRight="@dimen/_32sdp"
                android:textAlignment="center"
                app:titleTextColor="@color/ThemeColor">
    

    【讨论】:

    • 谢谢,看来ToolBar真的好用了
    猜你喜欢
    • 2014-05-04
    • 2015-06-02
    • 1970-01-01
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多