Android PopupWindow elevation does not show shadow

前端 未结 3 1116
抹茶落季
抹茶落季 2020-12-03 02:35

Android PopupWindow 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

3条回答
  •  囚心锁ツ
    2020-12-03 03:29

    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)

提交回复
热议问题