2017-02-17 86 views
2

我想改變導航抽屜菜單的顏色導航內容的顏色content.when特定標籤selected.I已經在下面的彩色圖像顯示在導航抽屜content.I要打紅色作爲選中時特定選項卡的文本顏色。如何改變的android系統

這是一個XML文件 -

<?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

回答

1

試試這個,

繪製/ 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> 

和佈局:

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

如果你想改變圖標顏色也然後使用應用程序:itemIconTint =「@繪製/ navigation_text_color」 – user2025187

+0

謝謝,它的工作。 –