How to remove indents between the names of Feed \ Interests, etc., and then I suffer for the second day and I can not find a solution. Can I explain in more detail?

enter image description here

  • show how you create and add menu items. - Nikotin N
  • depends on how your menu is made. - Vladyslav Matviienko
  • @metalurgus I create it according to the standard by creating a list of items in the / menu and importing into NavigationView through 'app: menu = "@ menu / drawer"', but I already understood how to change the standard NavigationView markup - Satanist Devilov
  • one
    @metalurgus right now sign for my decision - Satanist Devilov

1 answer 1

Change the standard markup NavigationView.

First we create a style for our NavigationView in the file /res/values/styles.xml

<style name="NavDrawerTextStyle"> <item name="android:textSize">16sp</item> <!-- Размер текста --> <item name="android:textAllCaps">true</item> <item name="android:itemBackground">@color/action_navigation_item_text_bg_color</item> <item name="android:textColor">@color/action_navigation_item_text_color</item> </style> <!-- Если chaked = true, то цвет текста оранжевый --> <style name="NavigationViewStyle"> <item name="android:paddingTop">2dp</item> <item name="android:listPreferredItemHeightSmall">40dp</item><!-- menu item height--> <item name="listPreferredItemHeightSmall">40dp</item><!-- menu item height--> <item name="android:listPreferredItemPaddingLeft">16dp</item> <item name="listPreferredItemPaddingLeft">16dp</item> </style> 

In the style of NavDrawerTextStyle we describe the style of the text that will be displayed in our menu.

In the style of NavigationViewStyle we describe the indents themselves. In the NavigationView is all on default .

android: listPreferredItemHeightSmall

Responsible for item height, i.e. Feed, Interests and everything that is in my menu.

android: listPreferredItemPaddingLeft

Responsible for the left margin.

In the / res / values ​​/ dimens file, just add this line.

 <dimen name="design_navigation_icon_padding" tools:override="true">16dp</dimen> 

Changes the distance to the right of the icon, i.e. the distance between the icon and the text.

In the end, this will be such a NavigationView, but without a header.

 <android.support.design.widget.NavigationView android:layout_below="@+id/drawer_viewpager" android:id="@+id/navigation_menu" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start" app:menu="@menu/drawer" app:theme="@style/NavigationViewStyle" app:itemIconTint="@color/colorAccent" app:itemTextAppearance="@style/NavDrawerTextStyle"/> 

I add the icon programmatically.

 navigationMenu.getMenu().findItem(R.id.nav_item_feed).setChecked(true); navigationMenu.getMenu().findItem(R.id.nav_item_feed).setIcon(R.drawable.happ_drawer_icon); 

enter image description here