Menu Color Hamburger NavigationView Android

2

Currently my menu looks black like the following image

And I would like it to be white, my xml is the following:

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="330dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer"
    android:background="@color/white"
    app:itemIconTint="@color/black"
    />

The back end is the following

    public void MenuConfiguracion() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.actionbar_toolbar);
        setSupportActionBar(toolbar);
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.bringToFront();
        drawer.requestLayout();


        final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        navigationView.bringToFront();
        navigationView.requestLayout();
}

The truth is I do not realize where this color is, I already tried changing in my THEME, from Light ah DarkLigth as I saw in some questions but it did not work,

I add new style

<style name="AppThemeMenu" parent="Theme.AppCompat.DayNight.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>

</style>

in the XML

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="330dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer"
    android:background="@color/white"
    android:theme="@style/AppThemeMenu"
    app:itemIconTint="@color/black"
    />
    
asked by Bruno Sosa Fast Tag 20.02.2018 в 14:59
source

2 answers

3

One option is to define the color in a style, within styles.xml (there may be several in your project), add the style with name DrawerIcon and define the color white:

<style name="DrawerIcon" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/white</item>
</style>

later check which theme uses the Activity that contains the NavigationDrawer within your AndroidManifest.xml ( android:theme="???" ) and add to this theme the style DrawerIcon .

For example, if your application uses the AppTheme style, then I must define the DrawerIcon style here:

  <style name="AppTheme">
        ...
        ...
        ...

        <item name="drawerArrowStyle">@style/DrawerIcon</item>

  </style>

Based on the above, you can easily change the color of the "hamburger" icon:

    
answered by 20.02.2018 / 16:37
source
1

It works for me by writing the secondary text color in the theme of the toolbar

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/mi_estilo"
app:layout_scrollFlags="scroll|enterAlways"
app:titleTextColor="@color/colorEncabezados"
app:popupTheme="@style/AppTheme.PopupOverlay">

This goes in styles.xml

<style name="mi_estilo" parent="AppTheme">
<item name="android:textColorSecondary">@color/colorAccent</item>
</style>
    
answered by 20.02.2018 в 17:20