2017-02-17 52 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

谢谢,它的工作。 –