2016-03-21 16 views
1

Ich erstelle meine eigene Aktionsleiste mit Menüelementen und daher Theme.AppCompat.Light.NoActionBar. Ich möchte die Aktionsleiste lila und die Titelfarbe weiß haben, aber im Moment ist es schwarz.So ändern Sie die Titelfarbe bei Verwendung von Theme.AppCompat.Light.NoActionBar

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

meine Aktionsleiste xml ist:

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/colorPrimary" 
    android:id="@+id/app_bar" 
    > 

Antwort

4

Wie in dieser Google+ pro-tip erklärt, Sie ThemeOverlay können nur bestimmte Dinge anpassen. Dies ist nützlich, wenn Sie Text Licht auf einem dunklen Hintergrund müssen machen, die durch Zugabe von android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" zu Ihrem Toolbar erreicht werden kann:

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/colorPrimary" 
    android:id="@+id/app_bar" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
> 

Diese Technik weiter in den Theming with AppCompat blog+video diskutiert wurde.

+0

Vielen Dank, das hat funktioniert! –

Verwandte Themen