Set the distance between the menu in a navigation drawer and the screen edge?
It worked for me:)
In NavigationView for Padding between the screen and the icon menu :
app:itemHorizontalPadding="40dp"
and for padding between the menu icon and the text use this:
app:itemIconPadding="28dp"
full code:
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"
app:itemTextColor="?android:textColorPrimary"
app:itemIconPadding="28dp"
app:itemHorizontalPadding="40dp" >
Reduce space between menu groups inside navigation drawer
I think you must override
design_navigation_separator_vertical_padding dimens
in your project dimes.xml
<dimen name="design_navigation_separator_vertical_padding" tools:override="true">0dp</dimen>
Setting a margin for NavigationDrawer items
Try this as item
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:padding="20dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#222"
android:text="bla bla bla" />
and main xml as this
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/drawer_layout">
<android.support.v4.widget.SwipeRefreshLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/refreshSites"
tools:context=".MyActivity">
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sitesList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"/>
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:layout_width="280dp"
android:layout_height="fill_parent"
android:id="@+id/drawerPane"
android:layout_gravity="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView android:id="@+id/left_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/white"
android:dividerHeight="0dp"
android:background="#FFF">
</ListView>
</LinearLayout>
</RelativeLayout>
Hope, this will help.
Android NavigationView: reduce space between icon and text and `itemBackground` not working
After digging through the source. I found that you could override a dimension resource to fix this.
<dimen tools:override="true" name="design_navigation_icon_padding">16dp</dimen>
Beware though that this will change the dimension resource everywhere!
You may also be able to copy the layout file and override that instead design_navigation_menu.xml
As for the different color edges, I set app:itemBackground="@android:color/transparent"
and then in the theme for the NavigationView set:
<item name="selectableItemBackground">@drawable/nav_drawer_item_selector</item>
You can handle both in the theme for your NavigationView as follows:
<item name="selectableItemBackground">@drawable/nav_drawer_item_selector</item>
<item name="itemBackground">@color/transparent</item>
nav_drawer_item_selector.xml looks like so:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/white_alpha_10" />
<item android:state_checked="true" android:drawable="@color/white_alpha_10" />
<item android:state_focused="true" android:drawable="@color/white_alpha_10" />
<item android:state_activated="true" android:drawable="@color/white_alpha_10" />
<item android:drawable="@color/transparent" />
</selector>
Change drawer gap between header group and first item menu
Thanks to azizbekian, his answer gived to me a great idea (maybe not the best but in my case more simple and fast to implement).
Basically, I add a layout with the same name (this will override it).
After that I change all that I need, so the result is this:
Related Topics
Java.Io.Ioexception: Permission Denied Cannot Create File
Open Play Store App from Browser Link
Send Post Request With Json Data Using Volley
I Get Fragment Not Attached to a Context. What Context Need to Use
How Disable Redirect in Webview
How to Stop Refreshing Recyclerview Data Scroll to Top Position Android Everytime
Retrofit:Getting Error ** End of Input At Line 1 Column 1**
How to Turn Off Suggestions in Edittext
How to Get Screen Dimensions as Pixels in Android
React Native: Java_Home Is Not Set and No 'Java' Command Could Be Found in Your Path
How to Completely Rename an Android Application
How to Scroll Scrollview to Bottom Programmatically in Android
How to Use Adb With Emulator Like Memu/Bluestacks/Nox App Player
How to Edit Files Inside the Android Adb Shell
How to Make Buttons Align At the Middle - Android Studio
Error:Binderproxy@45D459C0 Is Not Valid; Is Your Activity Running