Android的PopupWindow海拔不显示阴影海拔、阴影、Android、PopupWindow

由网友(絕版ァ愛戀♂)分享简介:当海拔设置 Popwindow 不显示阴影。这似乎从文档支持。我使用的5.0棒棒糖。 创建弹出如下所示: popupWindow =新PopupWindow(背景);    popupWindow.setOutsideTouchable(真);    popupWindow.setFocusable(真);...当海拔设置

Popwindow 不显示阴影。这似乎从文档支持。我使用的5.0棒棒糖。

创建弹出如下所示:

  popupWindow =新PopupWindow(背景);    popupWindow.setOutsideTouchable(真);    popupWindow.setFocusable(真);    popupWindow.setElevation(10);    popupWindow.setContentView(rootView);    popupWindow.showAtLocation(anchorView,Gravity.NO_GRAVITY,XPOS,yPos); 

解决方案

作为的由Android开发回答。

  Android开发,如何让PopupWindow弹出时外部控件不可点击

如果膨胀的视图不具有背景集合,或在弹出  窗口本身不具有背景设定(或具有透明  背景),那么你不会得到一个阴影。

这是我的情况,似乎是你的,因为你不使用setBackgroundDrawable。

这为我工作

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

我已经打开了新的问题,这表明他们更新的文件(的 HTTPS://$c$c.google.com/p/android/issues/detail ID = 174919 )

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);

解决方案

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)

阅读全文

相关推荐

最新文章