Android Popwindow does not show shadows when the elevation is set. It appears to support it from the documentation. I am using 5.0 Lollipop.
Creating the popup as follows:
popupWindow = new PopupWindow(context);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
popupWindow.setElevation(10);
popupWindow.setContentView(rootView);
popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, xPos, yPos);
For others who visit this answer and missed what the OP already had, you should set the elevation to create a shadow:
Depending on what your content view is, you might also need to set the background drawable, although this is not always necessary. If needed you can do as @Maragues suggested:
To support pre-Lollipop devices you could use a 9-patch or image that includes the shadow within it.
Code
This is the code for the image above.
Note:
The elevation is in pixels when set in code, but usually in dp when set in xml. You should convert a dp value to pixels when setting it in code.
As answered by an Android developer.
which was my case and seems to be yours, since you are not using setBackgroundDrawable.
This worked for me
I've opened a new issue suggesting that they update the documentation (https://code.google.com/p/android/issues/detail?id=174919)