2015-02-05 8 views
8

Mein Hauptthema auf Theme.AppCompat.Light basiert wie folgt:die 'Zurück' Pfeil Farbe in Actionmode Customizing mit AppCompat-v7

<style name="core" parent="Theme.AppCompat.Light" > 
    <!-- Material, Yo!--> 
    <item name="colorPrimary">@color/theme_main_color</item> 
    <item name="colorPrimaryDark">@color/deep_purple</item> 
    <item name="colorAccent">@color/theme_accent_color</item> 
    <item name="android:navigationBarColor" tools:ignore="NewApi">?attr/colorPrimary</item> 
    <!-- Toolbar --> 
    <item name="theme">@style/my_toolbar_theme</item> 
    <item name="drawerArrowStyle">@style/my_drawer_arrow</item> 
    <!-- Actionbar --> 
    <item name="android:actionBarDivider">@null</item> 
    <item name="android:actionBarTabStyle">@null</item> 
    <item name="android:actionBarTabBarStyle">@null</item> 
    <!-- Contextual Actionbar --> 
    <item name="windowActionModeOverlay">true</item> 
    <item name="actionModeBackground">?attr/colorAccent</item> 
    <item name="actionModeStyle">@style/my_actionmode_style</item> 
</style> 

<style name="my_drawer_arrow" parent="Widget.AppCompat.DrawerArrowToggle" > 
    <item name="spinBars">true</item> 
    <item name="color">@color/theme_accent_color</item> 
</style> 

<style name="my_toolbar_style"> 
    <item name="android:id">@id/toolbar</item> 
    <item name="android:minHeight">?attr/actionBarSize</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:background">?attr/colorPrimary</item> 
    <item name="android:elevation" tools:ignore="NewApi">5dp</item> 
</style> 

<style name="my_actionmode_style" parent="Widget.AppCompat.Light.ActionMode.Inverse" > 
    <item name="titleTextStyle">@style/my_actionmode_title_style</item> 
    <item name="subtitleTextStyle">@style/my_actionmode_subtitle_style</item> 
</style> 

<style name="my_toolbar_style.gradient"> 
    <item name="android:background">@drawable/ab_gradient_bg</item> 
</style> 

<style name="my_toolbar_theme" parent="ThemeOverlay.AppCompat.Dark.ActionBar" > 
    <!-- Customize the toolbar here --> 
</style> 

<style name="my_actionmode_title_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Title"> 
    <item name="android:textColor">@color/std_white</item> 
</style> 

<style name="my_actionmode_subtitle_style" parent="TextAppearance.AppCompat.Widget.ActionMode.Subtitle"> 
    <item name="android:textColor">@android:color/white</item> 
</style> 

In actionmode Ich weiß Titel sehen möchten/Untertitel mit einem weißen Pfeil zurück. Ich konnte die Textfarbe für Titel und Untertitel auf Weiß setzen, aber der Zurück-Pfeil bleibt schwarz. Dieses Problem tritt nur an Orten auf, an denen ich die SupportAction-Leiste und nicht die Symbolleiste verwende (der Zurück-Pfeil in der Symbolleiste ist weiß).

Dies ist meine Symbolleiste in ActionMode.

This is my toolbar in ActionMode

Dies ist ActionBar in ActionMode. Gleiches Telefon, gleiche App, gleiche Themen, nur eine andere Aktivität.

This is the actionbar in ActionMode

Ich kann nichts in den Themen finden, die diese Farbe bestimmen würde. Laut der Quelle ist das Symbol @drawable/abc_ic_ab_back_mtrl_am_alpha, was weiß ist, also muss etwas getönt werden. Woher kommt diese schwarze Farbe?

+0

Versuchen Sie folgendes: http://stackoverflow.com/questions/27861102/actionbardrawertoggle-v7-arrow-color – Quanturium

Antwort

5

hatte ich das gleiche Problem, und ich habe es gelöst, indem explizit auf das Symbol I im Stil verwenden möchten erklärt:

<item name="android:actionModeCloseDrawable">@drawable/ab_back</item> 

Wo @ ziehbar/ab_back von mir zur Verfügung gestellt.

Dies ist nicht ideal, da ich den Stil richtig einstellen und es die richtigen Farben vom übergeordneten Thema vererben lassen möchte, ohne so spezifische Details deklarieren zu müssen. Aber ich fühle alles um die ActionBar, SupportActionBar, SherlockActionBar, ActionBarActivity, FragmentActivityWithASherlockSupportActionToolbar ist SO kaputt und schlecht entwickelt, dass ich glücklich bin, es mit einer Problemumgehung zu lösen.

+3

Ja, ich nicht tun wollte. Es gibt eine Menge Diskrepanzen in den Support-Bibliotheken. Genug, um Steve Jobs jedes Mal im Grabe kichern zu lassen, wenn jemand _Fragmentation_ ... sagt – copolii

0

Try "colorControlNormal" Eigentum wie unten angegeben in Ihrer "NoActionBar Theme"

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

<style name="AppTheme.NoActionBar"> 
    <item name="colorControlNormal">@android:color/white</item> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 
18

dies mit AppCompat anzupassen:

In Ihrem App-Ebene Thema:

<style name="MyTheme" parent="Theme.AppCompat.Light"> 
    <item name="actionModeCloseDrawable">@drawable/ic_actionbar_back</item> 
    <item name="actionModeCloseButtonStyle">@style/myclosebutton</item> 
</style> 

In der CloseButtonStyle:

<style name="myclosebutton" parent="Widget.AppCompat.Light.ActionButton.CloseMode"> 
    <item name="android:tint">#ff0</item> <!-- whatever color --> 
</style> 
+0

Dies sollte als die richtige Antwort markiert werden. Es erlaubt, die Farbe des Zurück-Pfeils im Aktionsmodus zu ändern, ohne wissen zu müssen, welche Zeichen verwendet werden. Vielen Dank. – Rui

+0

Danke Kumpel .. endlich habe ich etwas gefunden, das funktioniert ...! –

-1

Ich habe beste Antwort für diese

Spannable text = new SpannableString(mode.getTitle()); 
        text.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorPrimaryDark)), 
          0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); 
        mode.setTitle(text); 
Verwandte Themen