【问题标题】:Android custom theme, color not changing for ToolbarAndroid自定义主题,工具栏颜色不变
【发布时间】:2021-06-09 15:40:26
【问题描述】:

请原谅简短的问题,但这似乎相对简单但无法更改工具栏颜色:

更改 textSize 甚至 ToolbarTitle 属性的父级确实会导致文本发生更改,但无论我如何尝试都无法更改颜色。

<style name="Theme.Custom" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="toolbarStyle">@style/Toolbar</item>
</style>

<style name="Toolbar" parent="Widget.MaterialComponents.Toolbar">
    <item name="titleTextAppearance">@style/ToolbarTitle</item>
    <item name="android:textColor">#FFFFFF</item>
</style>

<style name="ToolbarTitle" parent="TextAppearance.MaterialComponents.Button">
    <item name="android:textSize">12sp</item>
    <item name="android:textColor">#FFFFFF</item>
</style>

【问题讨论】:

    标签: android material-design


    【解决方案1】:

    只需将android:background 添加到您的工具栏主题即可更改工具栏颜色。 Ref

    <style name="Toolbar" parent="Widget.MaterialComponents.Toolbar">
        <item name="titleTextAppearance">@style/ToolbarTitle</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:background">#FF0000</item>
    </style>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多