我花了很多時間試圖弄清楚如何將一些簡單的樣式應用於工具欄,但完全陷入了困境。具體而言,我想更改標題和副標題以及溢出菜單圖標(三個點)的顏色。我可以在佈局中成功設置文本顏色,但不能在主題中設置,我不知道爲什麼。如何將主題應用於Android工具欄?
<android.support.v7.widget.Toolbar
theme="@style/Toolbar"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/orange"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
styles.xml:
<style name="Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="titleTextStyle">@style/ToolbarTitle</item>
<item name="titleTextAppearance">@style/ToolbarTitleTextAppearance</item>
<item name="popupTheme">@style/AppTheme.PopupOverlay</item>
</style>
<style name="ToolbarTitle" parent="Base.TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="titleTextAppearance">@style/ToolbarTitleTextAppearance</item>
<item name="android:textColor">#FF0000</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
</style>
的PopupOverlay主題應用到溢出菜單彈出,所以工具欄主題顯然是被應用,但TextAppearance不起作用,文本保持黑色。我嘗試了很多種替代形式,但沒有喜悅。當我嘗試一些,但它不起作用時,我不知道該從哪裏開始尋找理解原因。調試像這樣的主題問題的提示是值得歡迎的!對於什麼應該是非常簡單的UI樣式更改而言,這會讓人深感沮喪,但是佈局,樣式,主題的多個方面& AppCompat讓我完全迷惑和猜測。