2017-02-17 6 views
2

Ich möchte Farbe der Navigation Schublade Menü Inhalt.wenn eine bestimmte Registerkarte ausgewählt ist.Ich habe in Bild unten Farbe auf die Navigation Schublade Inhalt.Ich möchte rote Farbe als eine Textfarbe einer bestimmten Registerkarte, wenn sie ausgewählt wird.So ändern Sie die Farbe der Navigation Inhalt in Android

Dies ist xml File-

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="info.androidhive.navigationdrawer.activity.MainActivity"> 

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

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.AppBarOverlay" /> 

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


    <android.support.v4.widget.DrawerLayout 
     android:paddingTop="?attr/actionBarSize" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:openDrawer="start"> 
     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:paddingTop="?attr/actionBarSize" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true" 
      app:menu="@menu/activity_main_drawer" 
      /> 
     <FrameLayout 
      android:id="@+id/frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"></FrameLayout> 


    </android.support.v4.widget.DrawerLayout> 



    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     app:backgroundTint="@color/colorPrimaryDark" 
     app:srcCompat="@android:drawable/ic_dialog_email" /> 

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

enter image description here

Antwort

1

Try this,

ziehbar/navigation_text_color:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <!-- This is used when the Navigation Item is checked --> 
    <item android:color="#009688" android:state_checked="true" /> 
    <!-- This is the default text color --> 
    <item android:color="#E91E63" /> 
</selector> 

und Layout:

<android.support.design.widget.NavigationView 
     . 
     . 
     app:itemTextColor="@drawable/navigation_text_color"/> 
+0

Wenn Sie die Symbolfarbe auch ändern möchten, dann verwenden Sie App: itemIconTint = "@ drawable/navigation_text_color" – user2025187

+0

Danke, es funktioniert. –

Verwandte Themen