Reputation: 111
First, I want to say that I have modified the method needsDividerBefore and now the divider appeared between menu items. However, I want to customize this divider and I tried all the ways mentioned before but I could not succeed.
Second, the divider I want is as same as foursquare, twitter and instagram used. Is this a common divider or all these applications use a custom layout? I don't know but even if they use custom layouts, I want to add action buttons from menu.xml and how can I customize divider?
Upvotes: 1
Views: 2009
Reputation: 111
I could not find background attribute in MenuItem. This is the xml for MenuItem
<item
android:id="@+id/menu"
android:icon="@drawable/menu"
android:title="menu"
android:showAsAction="ifRoom|withText">
</item>
And then I added
android:actionLayout="@layout/divider"
And the divider.xml is below;
<?xml version="1.0" encoding="UTF-8"?><LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@color/black"
android:layout_marginRight="50dp" /></LinearLayout>
When I use this, the icon is unvisible. What is the best way to add a custom divider?
Upvotes: 0
Reputation: 76075
Modifying that method will only affect pre-ICS phones so you will still get the natural divider behavior on ICS+. This means that your app will look differently based on what version of Android is running it.
You can change the divider with the actionBarDivider
theme attribute.
Upvotes: 1