Reputation: 21
I have NavigationDrawerActivity. I want to set left margin to menu items.
I tried like this.
<style name="NavigationDrawerStyle" parent="AppTheme">
<item name="android:layout_marginLeft">@dimen/dimen20dp</item>
</style>
and applied this style to NavigationView
.
Margin left is set to both header part and list.
I want it to apply to only list.
Upvotes: 2
Views: 2067
Reputation: 363687
Use app:itemIconPadding
to change the margin between the icon and the text
<com.google.android.material.navigation.NavigationView
app:itemIconPadding="xxdp"
..>
Use the app:itemHorizontalPadding
to change the padding before the icon:
<com.google.android.material.navigation.NavigationView
app:itemHorizontalPadding="0dp"
/>
Use app:itemShapeInsetStart
to change the padding of the shape
<com.google.android.material.navigation.NavigationView
app:itemShapeInsetStart="0dp"
/>
You can also use a custom style:
<style name="CustomNavigationView" parent="Widget.MaterialComponents.NavigationView">
<item name="itemIconPadding">@dimen/.....</item>
<item name="itemHorizontalPadding">@dimen/....</item>
<item name="itemShapeInsetStart">@dimen/..../item>
</style>
Upvotes: 4