2017-11-04 10 views
0

Standardmäßig enthält meine Aktionsleiste einen weißen Text.Ändern der Textfarbe in der benutzerdefinierten Symbolleiste

Ich habe eine Ansicht, die eine benutzerdefinierte Symbolleiste verwendet, aber der Text zeigt stattdessen schwarz.

Ich kann nicht sehen, was das Problem ist. Ich vermute, es ist mit Vererbung zu tun?

Snippet von activity_stories.xml:

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.NoActionBar"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" /> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabMode="fixed" 
     app:tabGravity="fill"/> 

</android.support.design.widget.AppBarLayout> 

Mein styles.xml:

<resources> 

    <!-- Base application 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> 
     <item name="android:textColor">@android:color/black</item> 
    </style> 

    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 

Mein AndroidManifest.xml:

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".StoriesActivity" android:theme="@style/AppTheme.NoActionBar" /> 
    <activity android:name=".StoryBodyActivity"></activity> 

</application> 
+0

ändern Können Sie meine Antwort überprüfen? Danke. – KeLiuyue

Antwort

0

Meine Lösung war <activity android:name=".MainActivity" /> zu <activity android:name=".MainActivity" android:theme="@style/AppTheme.NoActionBar" />

0

1.Set android:textColorPrimary und android:textColorPrimaryInverse in verschiedenen Schnitten

2.Set in Toolbar

bereits.

<android.support.v7.widget.Toolbar 
    app:theme="@style/yourToolbar" /> 


<style name="yourToolbar" parent="Theme.AppCompat.NoActionBar"> 
    <!-- android:textColorPrimary is the color of the title text 
     in the Toolbar, in the Theme.AppCompat theme: --> 
    <item name="android:textColorPrimary">@color/my_color</item> 

    <!-- android:textColorPrimaryInverse is the color of the title 
     text in the Toolbar, in the Theme.AppCompat.Light theme: --> 
    <item name="android:textColorPrimaryInverse">@color/my_color</item> 
</style> 
Verwandte Themen