NavigationView Items Padding in Android

how to add padding between menu items in android?
space between navigation menu items android
bottomnavigationview item padding
android toolbar navigation icon padding
android navigation drawer change selected item background color
how to reduce space between menu items in android
navigation view android
custom menu item in navigation drawer android

How do I set padding for items inside NavigationView.I need to set paddingLeft for items as I have removed icons.What i have tried is this but it is not working:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<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"
    android:focusable="true"
    android:foreground="?attr/selectableItemBackground"
    app:headerLayout="@layout/nav_header_navigation_drawer"
    app:itemBackground="@drawable/selected_background"
    app:itemTextAppearance="@style/Drawer"
    app:menu="@menu/activity_navigation_drawer_drawer" />

My Drawer.xml file in styles:

<style name="Drawer">
    <item name="android:listPreferredItemPaddingLeft">50dp</item>
    <item name="android:textSize">30sp</item>
    <item name="android:typeface">serif</item>
</style>

In case anyone wants to adjust the padding for the items in the NavigationDrawer using the latest material design, checkout these new attributes app:itemIconPadding and app:itemHorizontalPadding.

app:itemIconPadding will adjust the padding between your icon and the item's text app:itemHorizontalPadding, as its name suggest, will adjust the padding from the left and right horizontally for the item.

<com.google.android.material.navigation.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"

            app:itemIconPadding="16dp"
            app:itemHorizontalPadding="10dp"

            app:menu="@menu/nav_drawer_menu" />`

How to overcome this item padding in 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 NavigationView android:id="#+id/nav_view"  Returns the horizontal (left and right) padding in pixels applied to menu items. int: getItemIconPadding() Returns the padding in pixels between the icon (if present) and the text of menu items. ColorStateList: getItemIconTintList() Returns the tint which is applied to our menu items' icons. int: getItemMaxLines()

Since you are using a menu without icons you can use the app:itemHorizontalPadding attribute:

<com.google.android.material.navigation.NavigationView
    app:itemHorizontalPadding="2dp"
    ../>

The result with default value and custom value:

Use the app:itemShapeInsetStart="0dp" to change the margin of the shape:

NavigationView, During the I/O Conference 2015, Google released NavigationView, which makes it Each item when clicked will switch the relevant fragment into the activity's i.e. the UI on top gets padding enough to not be obscured by the navigation bar. Android NavigationView represents a standard navigation menu for application. It is one of the way to implement navigation hierarchy on Android applications, some of the others are Tabs, Spinners etc. Before Android NavigationView, It was difficult to implement material navigation drawer using list view or linear layout with custom adapter.

You can add this value ion dimension file under the res->values->dimension folder and add the following line of code.

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

Reduce left margin for menu item of Navigation drawer?, r/androiddev: News for Android developers with the who, what, where when and how of the Android community. Probably mostly the how. Here, you'll … android.support.design.widget.NavigationView Represents a standard navigation menu for application. The menu contents can be populated by a menu resource file.

you can change "listPreferredItemHeightSmall" value for changing navigation item vertical padding in your application theme

<!-- Your application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <!-- THIS LINE-->
    <item name="listPreferredItemHeightSmall">54dp</item>
</style>

(default value is 48dp)

Fragment Navigation Drawer, NavigationView in Android, Android NavigationView example, Navigation View is us to implement the items using a ListView/RecyclerView by implementing a custom Adapter. android:paddingBottom="@dimen/activity_vertical_margin"  This example demonstrates how do I Use NavigationView in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

Set Margin to Navigation Drawer's Default Divider : androiddev, NavigationView is an easy way to display a navigation menu from a menu resource. You can use setNavigationItemSelectedListener to listen to item selection  The ActionBarDrawerToggle is initialised as: ActionBarDrawerToggle toggle = new ActionBarDrawerToggle ( this, drawer, toolbar, R. string .navigation_drawer_open, R. string .navigation_drawer_close); The ActionBarDrawerToggle is used with a DrawerLayout to implement the recommended functionality of Navigation Drawers.

NavigationView In Android, Is there a possibility to change space interval between image and text in PrimaryDrawerItem, I was changed whole element padding using  Android Navigation Drawer is a sliding panel menu that is used to display major modules of the application. We can use OnNavigationItemSelectedListener to get the

Navigation Views, The Android navigation drawer has become a ubiquitous UI feature on Android devices, but it's android:padding="16dp" android:text="master list item 1"/> . Instead of including a ListView inside NavigationView , we'll actually use the  If you want a fixed (non-scrolling) footer in your navigation menu, you need wrap NavigationView around another layout, like you’ve posted. NavigationView works like FrameLayout, so this ends up “stacking” the inner layout on top of the NavigationView menu items.

Comments
  • try this hope its gonna work for you. stackoverflow.com/a/39914592/7104450
  • Possible duplicate of How to overcome this item padding in navigation drawer?
  • @SumitShukla you want padding between icon and textview inside the naviagtionView..?
  • @SardarKhan. No I have removed all those icons and I want all textView to be padded from Left...
  • I have removed all the icons.so am i able to use it.
  • try adding icon and then try it.
  • But i am supposed to do it without icons.
  • why you don't want to show icons.? it can elaborate your text and make it easy for user.
  • I am asked to so.That's why!!