简体   繁体   English

带有Web视图的可滚动和可缩放视图

[英]Scrollable and zoomable view with webviews

Let me start by saying - I know there are quite a lot of posts on this issue. 首先,我要说-我知道有很多关于这个问题的文章。 I've been digging and testing it quite a bit, but couldn't come up with the proper solution to my specific requirements. 我已经进行了很多挖掘和测试,但是无法为我的特定需求提供适当的解决方案。

I need to have a master view with several webviews inside it, and more than one should be visible at a single moment. 我需要一个主视图,其中包含多个Web视图,并且一次可以看到多个Web视图。 For this master view - I need to be able to scroll it (to reveal invisible webviews) and to zoom (in order to focus on a single webview). 对于此主视图-我需要能够对其进行滚动(以显示不可见的Web视图)和进行缩放(以集中于单个Web视图)。

I've tried TableLayout, but had problems with the zoom (and painting issues with the scrolling). 我尝试了TableLayout,但是缩放出现了问题(滚动出现了绘画问题)。 I've tried scroll views, but also read it's not recommended. 我尝试过滚动视图,但也建议不要阅读。

Any ideas or recommendation regarding how to achieve this? 关于如何实现这一目标的任何想法或建议?

Thanks, yakobom 谢谢yakobom

A simple approach could be to have only one webview with the root html doc containing multiple iframes. 一种简单的方法是仅使用一个Web视图,其根HTML文档包含多个iframe。 Load each page in one of the iframes. 在其中一个iframe中加载每个页面。

This way the scrolling/zooming could be handled by the webview itself. 这样,滚动/缩放可以由webview本身处理。

通过在.xml文件中添加滚动视图并放置其余文本视图,然后在该滚动视图中编辑文本,可以实现可滚动视图。

to scrolling webview: 滚动网页视图:

 mWebView2.getSettings().setJavaScriptEnabled(true);
 mWebView2.getSettings().setLoadWithOverviewMode(true);
 mWebView2.getSettings().setUseWideViewPort(true);
 mWebView2.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
 mWebView2.setScrollbarFadingEnabled(true);

to zooming webview: 缩放网页视图:

webView.setInitialScale(50);
webPlanSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
webPlanSettings.setUseWideViewPort(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM