强制网页以适应网页视图 [英] Forcing a webpage to fit into a webview

查看:151
本文介绍了强制网页以适应网页视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是两件事情:

我需要显示一个网页视图,显示整个网页(水平),并且自动地缩小至任何必要显示整个页面边缘宽度到边缘。我很好奇,如果这
A)可以在所有完成
B)如果是这样,这是什么事情我可以只用web视图或控制
c)若我需要修改网页的HTML挤入任何容器恰好是。

I need to display a webview that shows the entire webpage (horizontally), and automatically shrinks it to whatever width necessary to display the entire page edge to edge. I'm curious if this a) can be done at all b) if so, is this something I can control with JUST the WebView or c) if I need to modify the HTML of the page to squeeze into whatever the container happens to be.

我有一个情况我需要显示的Facebook(与Twitter和Pinterest的)在缩放到设备的大小网页视图,我想,以确保网页视图显示整个网页,而不是创建水平滚动条。

I have a situation where I need to display Facebook (and Twitter and Pinterest) in WebViews that scale to the size of the device and I want to make sure the WebViews show the entire page rather than creating Horizontal scrollbars.

然后,我很好奇,如果有一些方法可以让我自动向下滚动到一个特定的web视图坐标,这样我可以在Twitter和Facebook都在顶部的巨型横幅下方向下滚动并没有显示用户的内容他们有向下手动滚动。

Then, I'm curious if there's some way I can auto scroll down to a specific coordinate from the WebView so that I can scroll down beneath the massive banners that Twitter and Facebook have at the top and display the users' content without them having to scroll down manually.

可以这样做?

推荐答案

为了让web视图缩小页面屏幕的宽度,在code。使用以下设置。

In order to have the WebView shrink the page to the width of the screen, use the following settings in your code.

WebView webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);

您可以使用:

int x = 0, y = THE_NUMBER_YOU_WANT;
view.scrollTo(x,y);

滚动到网页上的任何位置,确定你有多远向下滚动,将是具有挑战性的,但。

to scroll to any position on the webpage, determining how far you have to scroll down will be challenging though.

这篇关于强制网页以适应网页视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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