![](/img/trans.png)
[英]change android:Theme.Light to Theme.AppCompat.Light.DarkActionBar
[英]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.