gpt4 book ai didi

android - PopupWindow 在 Android 5.0 上与软按钮重叠

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:14:32 25 4
gpt4 key购买 nike

我有一个简单的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);

在 Lollipop 之前的设备上,这个弹出窗口看起来不错,但在 Android 5.0 上,弹出窗口与软按钮重叠:

PopupWindow Lollipop

这是 Android 4.4 设备上的 PopupWindow:

enter image description here

有谁知道为什么会发生这种情况以及如何解决这个问题?

最佳答案

这可能是 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);

关于android - PopupWindow 在 Android 5.0 上与软按钮重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30827576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com