Reputation: 137
I want to highlight navigation items like this:
But my current menu looks like this:
My menu.xml is
<?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?
Upvotes: 5
Views: 14878
Reputation: 7479
Give each group a unique id like this:
<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.
Upvotes: 24