Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 设置导航项目文本颜色为白色_Android_Android Layout_Android Navigationview - Fatal编程技术网

Android 设置导航项目文本颜色为白色

Android 设置导航项目文本颜色为白色,android,android-layout,android-navigationview,Android,Android Layout,Android Navigationview,我想设置导航菜单文字颜色为白色怎么能做到呢?? 请检查我下面的代码片段 我的导航菜单如下所示: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/nav_timer" android:icon="@drawable/ic

我想设置导航菜单文字颜色为白色怎么能做到呢??

请检查我下面的代码片段

我的导航菜单如下所示:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
    <item
        android:id="@+id/nav_timer"
        android:icon="@drawable/ic_av_timer_black_36dp"
        android:title="Timer"
        android:textColor="#000000"
        />
    <item
        android:id="@+id/nav_profile"
        android:icon="@drawable/ic_account_circle_black_48dp"
        android:title="Profile"
        >@color/menuColor</item>
    <item
        android:id="@+id/nav_logs"
        android:icon="@drawable/ic_assignment_black_48dp"
        android:title="Logs" />
    <item
        android:id="@+id/nav_changeBusiness"
        android:icon="@drawable/ic_business_black_48dp"
        android:title="Change Business" />
    <item
        android:id="@+id/nav_logout"
        android:icon="@drawable/ic_exit_to_app_black_48dp"
        android:title="Logout" />

@颜色/菜单颜色

您可以在导航视图下添加列表视图。然后,您可以使用textview添加自定义适配器

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    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=".MainActivity">

    <FrameLayout
        android:id="@+id/content_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include layout="@layout/main_toolbar" />

    </FrameLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"/>

        <ListView
            android:id="@+id/menuList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</android.support.v4.widget.DrawerLayout>

这会解决你的问题。这对我很有用。

在导航视图中添加app:itemTextColor=“@android:color/white”

<android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:itemTextColor="@android:color/white"
            android:fitsSystemWindows="true"
            app:menu="@menu/act_home_drawer_menu"
             />


它将为您提供所需的结果。

添加代码,您正在做什么?不要使用菜单项在导航视图中显示。使用我在回答中提到的Listview适配器,并根据您的需求进行定制。