i have seen some tutorials but couldn't got through. I want to show icons along with item text. Here is my menu item.
<item
android:id="@+id/share"
android:icon="@drawable/ic_share_grey600_18dp"
app:showAsAction="always|withText"
android:orderInCategory="1"
android:title="Share"/>
Here is my java code :
PopupMenu popup = new PopupMenu(context, holder.cardMenuButton);
popup.getMenuInflater().inflate(R.menu.card_overflow_menu, popup.getMenu());
popup.show();
I am developing my app in material design. But its only showing the text.
The simple answer is you can't. You can use a similar widget, ListPopWindow, which uses an adapter to draw its content, giving you the flexibility you need.
Edit. For the width problem you have to call setContentWidth. You can easily iterate on the adapter's dataset in order to calculate the max width, and use this value as parameter for setContentWidth