Android Oreo WebView在第二次加载后呈现的布局太小 [英] Android Oreo WebView renders layout too small after 2nd loading

查看:90
本文介绍了Android Oreo WebView在第二次加载后呈现的布局太小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些Android Oreo设备上,当我第一次在Webview上加载URL时,URL页面会正确加载.但是,当我再次加载URL时,页面被缩小了.在低于android oreo的设备上,该页面会为所有设备正确加载.

On some Android Oreo devices, when I load an url on webview for the first time, the URL page loads properly. However, when I load the URL again, the page is zoomed out. On devices lower than android oreo, the page loads properly for all devices.

此外,当您在后台终止应用程序并再次加载时,URL会正确加载.在第二次及其后的尝试中,它将再次显示缩小的版本.我在下面附加了加载的网址图片

Also, when you kill the app on the background and load again, the URL loads properly. On the second and succeeding tries, it shows the zoomed out version again. I attached the images of loaded URL below

以下是正确在网页视图中加载网页

Below is the correct loading of webpage on the webview

下面是在webview上显示的网页的小视图

Below is the small display of webpage on webview webview

Android XML代码:

Android XML Code:

<WebView
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

Java代码:

    private WebView mWebView;
    mWebView = (WebView) view.findViewById(R.id.content_view);
    mWebView.loadUrl("https://policies.google.com/");

URL: https://policies.google.com/

请注意,这也发生在其他URL中. https://policies.google.com/只是一个例子

Take note that this happen in other URLs too. https://policies.google.com/ is just an example

它适用于以下情况: 华为nova 2i RNE-L22,安卓8.0.0

It works on the following: Huawei nova 2i RNE-L22, Android 8.0.0

它不适用于以下项目 Android 8.1.0;像素2 Android 8.0.0;三星SM-G950FD Android 8.0.1;华为P20 EML-L29

It DOES NOT work on the following Android 8.1.0; Pixel 2 Android 8.0.0; Samsung SM-G950FD Android 8.0.1; Huawei P20 EML-L29

为什么会出现这种情况的任何建议或原因?如何解决这个问题?

Any suggestions or reasons as why this happens? How to fix this?

先谢谢了.

推荐答案

向Google团队询问此问题后, 表示可能是某些视口布局设置.由于遗留问题,Webview有一些不幸的默认值.

After asking google team about this issue, the said that it's probably some viewport layout settings. Webview has some unfortunate defaults due to legacy issues.,

添加webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);解决了该问题.

这篇关于Android Oreo WebView在第二次加载后呈现的布局太小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆