Good day.

There is an Android application, with a menu based on the component NavigationView. And when you click on any menu item, and a small hold, the menu bar in the form of animation begins to be highlighted in pink.

Can you please tell us the name of the attribute in XML styles that is responsible for this color? Already I looked through all the documentation, I tried many parameters, but I could not find the one I needed.

  • Did app:itemBackground try the app:itemBackground ? - Flippy

2 answers 2

For the color of the text - this is

 // FOR NAVIGATION VIEW ITEM TEXT COLOR int[][] state = new int[][] { // (Цвет текста всех "включеных" элементов бокового меню ) // (если этот массив не закоментировать, то остальные массивы работать не будут) // new int[] {android.R.attr.state_enabled}, // enabled new int[]{android.R.attr.state_checked}, // checked new int[]{android.R.attr.state_pressed}, // pressed new int[]{} }; int[] color = new int[]{ // Color.GREEN, Color.parseColor("#724646"), Color.parseColor("#724646"), Color.parseColor("#724646") }; ColorStateList csl = new ColorStateList(state, color); 

This is for icons.

  //FOR NAVIGATION VIEW ITEM ICON COLOR int[][] stateIcon = new int[][]{ // (Цвет текста всех "включеных" элементов бокового меню ) // (если этот массив не закоментировать, то остальные массивы работать не будут) // new int[] {android.R.attr.state_enabled}, // enabled new int[]{android.R.attr.state_checked}, // checked new int[]{android.R.attr.state_pressed}, // pressed new int[]{} }; int[] colorIcon = new int[]{ // Color.GREEN, Color.parseColor("#724646"), Color.parseColor("#724646"), Color.parseColor("#724646") }; ColorStateList csIcon = new ColorStateList(stateIcon, colorIcon); 

Further programmatically assign these statelists as:

 navigationView.setItemTextColor(csl); navigationView.setItemIconTintList(csIcon); 

    Try this:

     <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:itemBackground="@drawable/my_ripple" app:itemIconTint="#2196f3" // Цвет тени app:itemTextColor="#009688" // Цвет текста app:headerLayout="@layout/nav_header" app:menu="@menu/drawer_view" />