This has been posted many times, but none of the existing solution appears to work with API 21+. The default popup's background color is exactly the same as the default background color for the layouts.
This is what it looks like (The popup is over a gridview but it has no obvious 'boundary' which looks a little off)
Something like this is ideal,i.e, with a proper material design shadow. There's a solution for accomplishing this with the toolbar popup menu. Not with a 'normal' PopupMenu.
This old question is trying to accomplish the same, however the given solution now no longer works:
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:popupMenuStyle">@style/popupMenuStyle</item>
</style>
<style name="popupMenuStyle" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@color/bgPopumMenu</item>
</style>
And neither does setting a custom context wrapper:
Context wrapper = new ContextThemeWrapper(getContext(), R.style.PopupMenu);
PopupMenu popup = new PopupMenu(wrapper, anchorView);
So, I'm unable to even change the background color of the popupmenu, let alone have a proper material design shadow.
How to give PopupMenu a shadow? Or how do I at least use a custom background drawable (using which I could put in a 9 patch shadow)