Popup separator for the theme "Application Compatibility"

I used the theme style on the application side.

  <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 separator to my menu item. I tried so many things, but the divider does not apply ... Is there a way to show the separator?

+4
source share
7 answers

I have one solution. You can create pop-ups of your choice using program.use below the code to display the pop-up menu.

private ListPopupWindow listPopupWindow;
listPopupWindow = new ListPopupWindow(getApplicationContext());
listPopupWindow.setWidth(400);
listPopupWindow.setDropDownGravity(Gravity.CENTER);
listPopupWindow.setAdapter(new listpopupadapter(a, type));
listPopupWindow.setAnchorView(v);
listPopupWindow.show();

Here, listpopupadapter is the class for compiling your list, as shown below.

public class listpopupadapter extends BaseAdapter {
    ArrayList<String> a;
    String type;

    public listpopupadapter(ArrayList<String> a, String type) {
        this.a = a;
        this.type = type;
    }

    @Override
    public int getCount() {
        return a.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("ViewHolder")
    @Override
    public View getView(final int position, View convertView,
            ViewGroup parent) {
        // TODO Auto-generated method stub
        View root = LayoutInflater.from(parent.getContext()).inflate(
                R.layout.raw_filter, null);
    }
}
+1
source

, , Toolbar. Toolbar? , .

<style name="AppToolbarPopupTheme" parent="Widget.AppCompat.PopupMenu.Overflow">
    <item name="android:dropDownListViewStyle">@style/AppDropDownListViewStyle</item>
</style>

<style name="AppDropDownListViewStyle" parent="Widget.AppCompat.ListView.DropDown">
    <item name="android:divider">@drawable/line_divider</item>
    <item name="android:dividerHeight">1dp</item>
</style>

Toolbar

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:popupTheme="@style/AppToolbarPopupTheme">

</android.support.v7.widget.Toolbar>
+2

. :

<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>

: ?

+2

,

<group>
    <!--add it like as a separator-->
    <item
        android:title=""
        android:showAsAction="always"
        android:enabled="false" />
</group>
+1

Material . , .

(, @android: style/Widget.ListPopupWindow),

<!-- Change Overflow Menu ListView Divider Property -->
<style name="PopupMenuListView" parent="android:Widget.ListPopupWindow">
    <item name="android:divider">#FF0000</item>
    <item name="android:dividerHeight">2dp</item>
</style>
+1

if you have not found the answer to this question, here is how it works for me, using the style:

    <style name="PopupMenu">
    <item name="android:itemBackground">@color/background_medium_gray</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:colorBackground">@color/BackgroundGray</item>
    <item name="android:dividerHeight">1dp</item>
</style>

    Context context = new ContextThemeWrapper(getActivity(), R.style.PopupMenu);
    final PopupMenu popupMenu = new PopupMenu(context, view);

    final MenuInflater menuInflater = popupMenu.getMenuInflater();
+1
source

I made a driver application that needed a popup that I came into, while I used this one. So please try this. Perhaps this will help.

<activity
    android:name="driver_activity_name
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />
0
source

All Articles