Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popup menu divider for App compat theme

I used app compat theme style .

  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
        <item name="android:itemTextAppearance">@style/myCustomMenuTextApearance</item>
        <item name="android:listPopupWindowStyle">@style/PopupMenuStyle</item>

    </style>
    <style name="PopupMenuStyle" parent="Widget.AppCompat.ListPopupWindow">
        <item name="android:divider">@drawable/devider</item>
        <item name="android:dividerHeight">2dp</item>
    </style>

    <style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@color/search_panel_color</item>
        <item name="android:textColor">@color/activity_button_text_color</item>
        <item name="android:shadowColor">@color/activity_theam_color</item>


    </style>

    <style name="myCustomMenuTextApearance" parent="@android:style/TextAppearance.Widget.TextView.PopupMenu">
        <item name="android:textColor">@color/activity_theam_color</item>
    </style>

I want to add a divider in my menu item. I've tried so many things, but the divider is not applying... Is there any way to show the divider?

like image 905
Learning Always Avatar asked Dec 08 '22 23:12

Learning Always


1 Answers

I also have the same problem. The solution is like this:

<style name="PopupMenuListView" parent="@style/Widget.AppCompat.ListView.DropDown">
    <item name="android:divider">#000000</item>
    <item name="android:dividerHeight">1dp</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">   
  <item name="android:dropDownListViewStyle">@style/PopupMenuListView</item>
</style>

You can also refer to the following link: How to add dividers between specific menu items?

like image 66
Jiangbo Wang Avatar answered Dec 10 '22 12:12

Jiangbo Wang