Hello guys I'm trying to change the height of my Navigation Drawer items and I don't know how, I've looked everywhere and did my best but nothing seems to work..
This is my Navigation Drawer item which is customised to have a text under that image but also I want that image to be a little bigger.
The result I am looking up to is this:
With around 75dp of height for each item and also I want the menu to be shorter on the width to give that look in that image.
I am using a custom layout for my items of course, which I named: menu_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_margin="10dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:src="@drawable/menu_icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu Title"
android:textSize="16sp"
android:textColor="@color/white" />
</LinearLayout>
my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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:background="@color/colorPrimaryDark"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
and finally the menu; activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/nav_profile"
app:actionLayout="@layout/menu_item"/>
</menu>
Any ideas how to achieve what I want? Thanks in advance
EDIT: When I enlarge the image in my custom item as follows:
this is in menu_item.xml
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:src="@drawable/menu_icon"/>
..I get this result:
As you see my image is bigger than the item..
add this to your styles.xml
<style name="NavigationTheme" parent="AppTheme">
<item name="listPreferredItemHeightSmall">60dp</item><!-- menu item height- vary as u need -->
</style>
and your navigation view in drawer layout shd include that theme lik this
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:theme="@style/NavigationTheme"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
make custom layout
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/white"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<include layout="@layout/custom_view"/>
</android.support.design.widget.NavigationView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With