android - PopupWindow重叠Android 5.0上的软按钮

android - PopupWindow重叠Android 5.0上的软按钮,第1张

我有一个简单的SEVERE: Job run failed with unexpected RuntimeException: Exception invoking Window.getComputedStyle() with arguments [Text, String] ======= EXCEPTION START ======== Exception class=[java.lang.IllegalArgumentException] com.gargoylesoftware.htmlunit.ScriptException: Exception invoking Window.getComputedStyle() with arguments [Text, String] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:847) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:779) at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:233) at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:762) at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.accessPopupWindow0(XMLHttpRequest.java:104) at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.run(XMLHttpRequest.java:623) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:415) at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:167) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.IllegalArgumentException: Exception invoking Window.getComputedStyle() with arguments [Text, String] at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:193) at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:449) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1536) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3286) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doRun(JavaScriptEngine.java:772) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:832) ... 13 more Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@4d3015e7 at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:153) ... 22 more ,我使用以下代码创建(代码在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上,弹出窗口与软按钮重叠:

android - PopupWindow重叠Android 5.0上的软按钮,PopupWindow Lollipop,第2张

以下是Android 4.4设备上的最佳答案:

android - PopupWindow重叠Android 5.0上的软按钮,enter image description here,第3张

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

1 个答案:

y

答案 0 :(得分:16)

这可能是android api 21中的错误,这就是为什么他们在api 22中引入popup.setAttachedInDecor(true/false);方法的原因 但是如果有锻炼,您可以为弹出窗口设置正确的Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int winHeight = getWindow().getDecorView().getHeight(); popup.showAtLocation(rootView, Gravity.BOTTOM, 0, winHeight-rect.bottom); 坐标,如下所示:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复