简体   繁体   中英

Customize Navigationview menu UI Android

I am using NavigationView control of android to create sliding drawer. All is fine except spacing between Menu Items in navigation view as shown in image.

Thank you in advance guys 在此处输入图片说明

Navigationview

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="start"
    app:headerLayout="@layout/homescreen_header"
    app:menu="@menu/homescreen_nav_drawer"

    app:itemIconTint="@color/green"
    app:itemTextColor="@color/White"
    app:theme="@style/NavigationView"
    app:itemBackground="@color/nav_item_bg"
    android:background="@color/nav_item_bg"
    />

<style name="NavigationView" >
    <item name="android:listDivider">@android:color/black</item>
</style>

create a style with

   <style name="NavigationViewStyle">
    <item name="android:listPreferredItemHeightSmall">25dp</item><!-- menu item height-->
</style>

and apply this style to NavigationView

 app:theme="@style/NavigationViewStyle"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM