簡體   English   中英

Android 自定義主題,工具欄顏色不變

[英]Android custom theme, color not changing for Toolbar

請原諒簡短的問題,但這似乎相對簡單但無法更改工具欄顏色:

在此處輸入圖像描述

更改 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:background添加到您的工具欄主題即可更改工具欄顏色。 參考

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM