我有一个简单的PopupWindow,我使用以下代码创建(代码在C#中,Java代码应该基本相同)
View popupView = LayoutInflater.From(this.Activity).Inflate(Resource.Layout.LectionFooter, null);
var popup = new PopupWindow(popupView, ViewGroup.LayoutParams.MatchParent,
ViewGroup.LayoutParams.WrapContent, false)
{
OutsideTouchable = true,
AnimationStyle = Resource.Style.FooterAnimation
};
popup.SetBackgroundDrawable(new BitmapDrawable());
popup.ShowAtLocation(rootView, GravityFlags.Bottom, 0, 0);
Run Code Online (Sandbox Code Playgroud)
在pre-Lollipop设备上,这个弹出窗口看起来不错,但在Android 5.0上,弹出窗口与软按钮重叠:

这PopupWindow是Android 4.4设备:

有谁知道为什么会发生这种情况以及如何解决这个问题?
Vil*_*len 16
这可能是android api 21中的错误,这就是他们引入popup.setAttachedInDecor(true/false)的原因; 在api 22中的方法但是有一个锻炼,你可以y为弹出窗口设置正确的坐标,如下所示:
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
int winHeight = getWindow().getDecorView().getHeight();
popup.showAtLocation(rootView, Gravity.BOTTOM, 0, winHeight-rect.bottom);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1744 次 |
| 最近记录: |