Android PopupWindow elevation does not show shadow

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:

  • Provided Gradle Dependency Is AAR not JAR
  • GATT callback fails to register
  • Dealing with implicit intent future deprecation in Lollipop
  • Android Studio Espresso Testing Error: Empty Test Suite
  • How to use a XML shape drawable?
  • This application does not have the debuggable attribute enabled in its manifest
  •     popupWindow = new PopupWindow(context);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setFocusable(true);
        popupWindow.setElevation(10);
        popupWindow.setContentView(rootView);
        popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, xPos, yPos);
    

  • Aapt_rules.txt not found when building apk in android studio
  • How to resolve java.util.zip.ZipException?
  • How to set height and width of compound drawable texview in xml?
  • Best way to work with dates in Android SQLite
  • Limitations of Video Capture in Phone Gap + Native Plugins
  • Where is the warnings view in Android Studio?
  • One Solution collect form web for “Android PopupWindow elevation does not show shadow”

    As answered by an Android developer.

    If the inflated view doesn’t have a background set, or the popup
    window itself doesn’t have a background set (or has a transparent
    background) then you won’t get a shadow.

    which was my case and seems to be yours, since you are not using setBackgroundDrawable.

    This worked for me

    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    

    I’ve opened a new issue suggesting that they update the documentation (https://code.google.com/p/android/issues/detail?id=174919)

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.