gpt4 book ai didi

Android Web View 在布局宽度变化时被拉伸(stretch)

转载 作者:行者123 更新时间:2023-11-30 03:47:37 31 4
gpt4 key购买 nike

我在 native 应用程序中渲染 webview 时遇到了困难,我在下面粘贴了一些屏幕截图,显示了每次宽度发生变化时 webview 的行为。

我还使用抽屉菜单,每次打开菜单抽屉时,webview 都会向右移动

加载 WebVIEW 时的屏幕截图

enter image description here

直到现在它似乎还不错,但现在当我打开和关闭抽屉菜单时,它不会将宽度更改回 100% 并保持在 50%

打开和关闭抽屉菜单后

enter image description here

当我打开抽屉菜单时,它也会模糊 webview

抽屉菜单打开时的屏幕截图

enter image description here

我也尝试了一些不同的 webview 设置,但都没有用,我的 webview java 代码也在这里

Java代码

                 mWebView = (WebView) findViewById( R.id.webView1 );
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(false);
mWebView.getSettings().setBuiltInZoomControls(false);
// Load URL
mWebView.loadUrl(requestUrl);

最佳答案

Following our discussion ,似乎问题与 android-menudrawer 库有关。具体来说,抽屉打开后硬件加速小部件无法正确显示,如 this issue concerning MapView v2 所述。 .

最基本的解决方案是通过在 list 中设置 android:hardwareAccelerated="false" 来禁用硬件加速,但我鼓励您探索更好的解决方案,例如 this one上述问题的作者建议:

I discovered an easy hack.

You simply create RelativeLayout with content placeholder andtransparent overlay that always visible. Every click events insidecontent works ok and bug also disappears:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:id="@+id/fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" />

</RelativeLayout>

关于Android Web View 在布局宽度变化时被拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14712876/

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