Left margin between icons and NavigationView
android, android-layout, android-view, java, navigationview
Solution
The xml layout of that item is `design_navigation_item.xml`
<android.support.design.internal.NavigationMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:foreground="?attr/selectableItemBackground"
android:focusable="true"/>
As you can see, paddings that are applied are taken from the activity's theme - `listPreferredItemPaddingLeft` and `listPreferredItemPaddingRight`. Thus, you have to apply your custom theme to `NavigationView` overriding those attributes with necessary values.
In `styles.xml`:
<style name="MyNavigationViewItemStyle" parent="AppTheme">
<item name="listPreferredItemPaddingLeft">0dp</item>
<item name="listPreferredItemPaddingRight">0dp</item>
</style>
We want to change only those two attributes from activity's theme, thus we are extending the theme, that is applied to the activity.
In layout `xml`:
<android.support.design.widget.NavigationView
...
app:theme="@style/MyNavigationViewItemStyle"/>
Result
Problem
I have to add a left margin between the icons and the `NavigationView`, in arrow in the image bellow: I know that according to google specs, this margin must have `16dp` but I need to change it. I have tried: ``` <dimen tools:override="true" name="design_navigation_icon_padding">64dp</dimen> <dimen tools:override="true" name="design_navigation_separator_vertical_padding">20dp</dimen> ``` But still not working. Any ideas?