So ändern Sie die ActionBar-action-text Farbe mit AppCompat
Ich versuche, ändern Sie die text-Farbe eines Menü "Aktion" Element auf der Menüleiste. Mit app-compat. Auch die überlauf-Symbol nicht ändern. Hier ist meine benutzerdefinierte Stil styles.xml -Dateien.
res/values/styles.xml
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<!-- Setting values in the default namespace affects API levels 7-13 -->
<item name="actionBarStyle">@style/MyStyledActionBar</item>
</style>
<style name="MyStyledActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- Setting values in the default namespace affects API levels 7-13 -->
<item name="background">@drawable/bg_action_bar</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
<item name="actionMenuTextAppearance">@style/MyActionBarMenuText</item>
<item name="actionMenuTextColor">@style/MyActionBarMenuText</item>
<item name="actionOverflowButtonStyle">@style/MyActionButtonOverFlow</item>
</style>
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/font_half_white</item>
</style>
<style name="MyActionBarMenuText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:textColor">@color/font_half_white</item>
</style>
<style name="MyActionButtonOverFlow" parent="@style/Widget.AppCompat.Light.ActionButton.Overflow">
<item name="android:src">@drawable/ic_action_search</item>
</style>
res/values-14/styles.xml
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<!-- Setting values in the android namespace affects API levels 14+ -->
<item name="android:actionBarStyle">@style/MyStyledActionBar</item>
</style>
<style name="MyStyledActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- Setting values in the android namespace affects API levels 14+ -->
<item name="android:background">@drawable/bg_action_bar</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:actionMenuTextAppearance">@style/MyActionBarMenuText</item>
<item name="android:actionMenuTextColor">@style/MyActionBarMenuText</item>
<item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverFlow</item>
</style>
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/font_half_white</item>
</style>
<style name="MyActionBarMenuText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:textColor">@color/font_half_white</item>
</style>
<style name="MyActionButtonOverFlow" parent="@style/Widget.AppCompat.Light.Base.ActionButton.Overflow">
<item name="android:src">@drawable/ic_action_search</item>
</style>
res/colors.xml
#F3F3F3
Den text Farbe immer noch schwarz, nicht in weiß ändern. Hat jemand erfolgreich geändert wurde der action-Menü-text-Farbe. Schlagen Sie bitte ein paar Einsichten. Ich Teste auf dem nexus5 4.4-Gerät.
InformationsquelleAutor der Frage Mani | 2014-03-26
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
Verwenden
Statt
in
res/values-14/styles.xml
In
res/values/styles.xml
Ich verwendete eine Rote Farbe zum testen. Siehe Menü "Aktion" Element Haus, das rot in der snap
Edit:
Vollständigen Code
In
res/values-14/styles.xml
Dann in res/values/stles.xml
In manifest
android:theme="@style/AppBaseTheme" >
Anderen snap
InformationsquelleAutor der Antwort Raghunandan
Können Sie diese verwenden, ändern Sie den text in der Aktionsleiste unabhängig von Ihrer appcompat-version.Geben Sie die gewünschte Farbe hex-code, und fügen Sie diese in der onCreate().
InformationsquelleAutor der Antwort onexf
Überprüfen Sie, dass in Ihrer layout-xml-Datei, die Sie nicht haben, eine
android:theme
angegebene Attribut für Ihre<Toolbar>
haben, würden sich die Priorität über das HauptthemaÜberschreiben Ihre
actionBarStyle
Attribut wie hingewiesen überall über das Internet.InformationsquelleAutor der Antwort DoruChidean