I'm trying to upgrade my PopupMenu so it would come with icons and custom styles.
I have created a new layout for it
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:id="@+id/layout_sharea"
android:background="@drawable/share"
android:paddingLeft="10.0dip"
android:paddingRight="10.0dip"
android:layout_width="wrap_content"
android:layout_height="50.0dip"
android:onClick="share">
<TextView
android:id="@+id/sharetexta"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/share"
android:drawableLeft="@drawable/share_button"
android:drawablePadding="10.0dip"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_shareb"
android:background="@drawable/share"
android:paddingLeft="10.0dip"
android:paddingRight="10.0dip"
android:layout_width="wrap_content"
android:layout_height="50.0dip"
android:layout_below="@+id/layout_sharea"
android:onClick="share">
<TextView
android:id="@+id/sharetextb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/share"
android:drawableLeft="@drawable/share_button"
android:drawablePadding="10.0dip"
android:layout_centerVertical="true" />
</RelativeLayout>
</RelativeLayout>
I want the PopupMenu to be customized (to be this layout) like in this picture
A PopupMenu is meant for displaying Menus and there really isn't a good way of customizing the appearance of the menu items. If you want something more flexible, your answer is ListPopupWindow.
Here is my demo for custom
ListPopupWindow
by custom adapterModel
ListAdapter
item_list_popup.xml
Finally, show
ListPopupWindow
(In this demo, I show MATCH_PARENT popup here, you can show a specific with for popup (eg: 100px, 200px,...) If you set popup width = WRAP_CONTENT, popup width will equals ANCHOR width)
Example using
DEMO