Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Navigation Drawer Icon and Text Spacing

I am wondering how do we change the spacing between the icon and the text?

Is it doable?

Any thoughts?

Thank you

enter image description here

like image 784
JayVDiyk Avatar asked Feb 14 '16 13:02

JayVDiyk


People also ask

How do I get my navigation drawer to open full screen?

So to make full drawer just give android:layout_marginStart="-64dp" to navigation view or the container where the drawer will be loaded. Save this answer.

How do I change my navigation drawer to open from right to left?

set DrawerLayout tools:openDrawer="end" set NavigationView android:layout_gravity="end" change tag view from androidx.


4 Answers

Add the following line to app\src\main\res\values\dimens.xml file. No need to add new layout.

<dimen tools:override="true" name="design_navigation_icon_padding">5dp</dimen>
like image 112
Asad Rao Avatar answered Oct 20 '22 16:10

Asad Rao


I added one line to xml: app:itemIconPadding="@dimen/space24" and it`s worked

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@android:color/white"
    android:clipToPadding="false"
    android:paddingBottom="@dimen/space48"
    app:headerLayout="@layout/layout_nav_header"
    app:insetForeground="@color/black"
    **app:itemIconPadding="@dimen/space24"**
    app:itemBackground="@drawable/background_selected_menu"
    app:itemHorizontalPadding="@dimen/horizontal_padding_on_nav_drawer"
    app:menu="@menu/drawer">
like image 31
Vadym Gryganskiy Avatar answered Oct 20 '22 17:10

Vadym Gryganskiy


If you change in your dimens.xml file you'll change on all of your project. I suggest you to change locally, just in NavigationView, like Vadym purpouse. Or you can change there like that:

<com.google.android.material.navigation.NavigationView
    app:itemIconPadding="4dp"
    ../>

This worked perfectly to me, and you can just change the value of the padding to everthing that you want.

like image 3
Raphael Rodrigues Avatar answered Oct 20 '22 17:10

Raphael Rodrigues


You will need another layout which you will inflate. In the layout, you can set the margin to what you want. Inflater allows you to adapt a layout to a view. check this out http://developer.android.com/reference/android/view/LayoutInflater.html or this http://khajanpndey.blogspot.com.ng/2012/12/android-layoutinflater-tutorial.html

Whichever view you are using, checkout how you can inflate the view. Hope this help.

like image 1
Aliyu Abdullahi Avatar answered Oct 20 '22 15:10

Aliyu Abdullahi