Android响应式网站显示在浏览器中,而不显示在Webview中 [英] Android responsive Website is shown in Browser, but not in Webview

查看:73
本文介绍了Android响应式网站显示在浏览器中,而不显示在Webview中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个Webview,该Webview应该显示一个响应性网站.用于显示移动版本的设备宽度限制为767像素,因此分辨率为1280x720的智能手机可以正确显示移动网站.

in my app I have a webview, which should display a responsive website. The device width for showing the mobile version is limited by 767 px, so the smartphones with a 1280x720 resolution displays the mobile website correct.

当我现在在s4上打开应用程序(分辨率:1920 x 1080)时,我希望Webview能够显示正常的桌面网站并且确实如此.但是,当我在普通的网络浏览器(例如Chrome)中打开它时,会显示响应式布局.

When I now open the app on my s4 (resolution: 1920 x 1080) I expect the webview, to show the normal desktop website and it does. But when I open it in normal web browser like Chrome, the responsive layout is shown.

有人可以解释这种行为吗?是否有可能在s4的我的webview中显示响应式网站?

Can anyone explain that behaviour? Is it possible to also show the responsive website in my webview on the s4?

网页包含以下内容

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

问候,珍妮摩

推荐答案

如果您没有先在应用中导入 javascript ,则可以尝试编写以下代码行,我将给出示例代码需要启用 javascript ,然后将这些代码行添加到 Android Webview

You can try writing this line of codes i am giving the example code if you didn't import javascript in your app first you need to enable javascript and then add these lines of code in the Android webview

 WebSettings webSettings = mWebview.getSettings();
 webSettings.setJavaScriptEnabled(true);
 webSettings.setUseWideViewPort(true);
 webSettings.setLoadWithOverviewMode(true);

尝试添加这些行可能对我有帮助,并且对我有用

Try adding these lines it may help i tried and it works for me

这篇关于Android响应式网站显示在浏览器中,而不显示在Webview中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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