I am using a custom menu in a navigation drawer. I would like to only reduce the left margin of the menu items and move the image view a little closer to margin (towards the left). I have already made the dimension changed for reducing the bottom margin and move the image view and text view.
<!-- Override the private variables in navigation drawer-->
<dimen name="design_navigation_icon_size">45dp</dimen>
<dimen name="design_navigation_icon_padding">5dp</dimen>
<dimen name="design_navigation_separator_vertical_padding">0dp</dimen>
<dimen name="design_navigation_seperator_left_margin">0dp</dimen>
I would only like to reduce the 16dp space for the image. Is there any dimension variable that can be over-ridden to do this ?
NavigatonView:
<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:headerLayout="@layout/nav_header_main"
app:itemIconTint="@null"
app:menu="@menu/activity_main_drawer"
app:itemTextAppearance="@style/NavigationDrawerStyle">
I have added
tools:override="true"
in the DrawerLayout.
The menu_drawer looks like this :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/grp1" android:checkableBehavior="single">
<item
android:id="@+id/navigation_item_1"
android:icon="@drawable/menu_home_unselected"
android:title="Home" />
</group>
<group android:id="@+id/grp2" android:checkableBehavior="single" >
<item
android:id="@+id/navigation_item_2"
android:icon="@drawable/menu_identify"
android:title="Identity" />
</group>
<group android:id="@+id/grp3" android:checkableBehavior="single" >
<item
android:id="@+id/navigation_item_3"
android:icon="@drawable/menu_self_disclosure"
android:title="Disclosure" />
</group>
</menu>
Use this
<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"/>
Override the listPreferredItemPaddingLeft property
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- HERE-->
<item name="listPreferredItemPaddingLeft">18dp</item>
</style>
set listPreferredItemPaddingLeft as required.