Is it possible to take view in menu items of toolbar?

I want view like shown in yellow color between two menu items of toolbar.
Simply create a divider line view in xml file to show a divider line.
dividerLine.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<View
android:layout_width="1dp"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/darker_gray"/>
</LinearLayout>
and set actionLayout to an item in menu xml to show divider line
activity_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/your_icon1"
android:icon="@drawable/image1"
android:title="@string/text1"
app:showAsAction="always"
/>
<item android:id="@+id/icon2TricktoShowDividerLine"
android:actionLayout="@layout/dividerLine"
app:showAsAction="always"
android:title="@string/text2" />
<item android:id="@+id/your_icon3"
android:icon="@drawable/icon"
android:title="@string/text3"
app:showAsAction="always" />
</menu>
android:actionLayout="@layout/dividerLine" shows divider line between menu items. Hope this helps you.
Updated
I am getting this type of view from my above code :

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