[英]How to draw a line between menu item in navigation drawer
I want to highlight navigation items like this:我想突出显示这样的导航项目:
But my current menu looks like this:但我目前的菜单是这样的:
My menu.xml is我的 menu.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">
<group android:checkableBehavior="single">
<group android:checkableBehavior="single">
<item android:id="@+id/home"
android:title="Home"
android:icon="@drawable/ic_action_home_page"/></group>
<group android:checkableBehavior="single">
<item android:id="@+id/p_profile"
android:title="Payment Profile"
android:icon="@drawable/ic_action_payment_profile"/></group>
<group android:checkableBehavior="single">
<item android:id="@+id/p_history"
android:title="Payment history"
android:icon="@drawable/ic_action_payment_history"/></group>
<group android:checkableBehavior="single">
<item android:id="@+id/m_cards"
android:title="My cards"
android:icon="@drawable/ic_action_my_card"/></group>
<group android:checkableBehavior="single">
<item android:id="@+id/menu_friends"
android:title="Friends"
android:icon="@drawable/search_people"/></group>
<group android:checkableBehavior="single">
<item android:id="@+id/notification"
android:title="Notification"
android:icon="@drawable/ic_action_notification"/></group>
<group android:checkableBehavior="single">
<item android:id="@+id/about"
android:title="About"
android:icon="@drawable/ic_action_about_us"/></group>
</group>
</menu>
How can I create the above highlight effect?如何创建上述高光效果?
Give each group a unique id like this:为每个组提供一个唯一的 id,如下所示:
<group android:checkableBehavior="single"
android:id="@+id/group1">
It'll draw those lines for you between any two groups.它会为您在任何两个组之间划出这些界限。
EDIT : Since the line is now showing but it's black on the black background, refer to this question to see how to change the color of the divider.编辑:由于线条现在显示但在黑色背景上是黑色的,请参阅此问题以了解如何更改分隔线的颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.