7

I'm trying to add a divider to my toolbar option menu, and i can't make it to work. How can I add a divider as shown in the image below:

enter image description here

Thanks.

Sharas
  • 1,985
  • 3
  • 20
  • 43

2 Answers2

3

For Android 6.0 Google remove dividers.

Material Themes doesn't display it.

Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119
0

can you try this code :

  <menu 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"
   tools:context=".MainActivity">

    <group android:id="@+id/grpSort" android:checkableBehavior="single" >
     <item
        android:id="@+id/action_sort"
        android:checked="true"
        android:icon="@drawable/ic_sort"
        android:title="@string/sort" />
   </group>

   <group android:id="@+id/grpHelp" android:checkableBehavior="single" >
    <item
        android:id="@+id/action_Help"
        android:icon="@drawable/ic_help"
        android:title="@string/help" />
   </group>

It's important to add a unique id to each <group>.

Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
MrZ
  • 560
  • 2
  • 12
  • 1
    Thanks, I saw this option in other questions and it didn't work for me. I wonder, maybe the problem is that the divider has the same color as the background, so it actually, transparent? – Sharas Mar 17 '16 at 15:57