机器人的WebView滚动

机器人的WebView滚动

本文介绍了机器人的WebView滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个基于浏览器的在Android的WebView类。我想启用的web视图水平和垂直滚动,并希望它准确地表现得像Android浏览器?有没有在清单文件中的任何设置的或将我覆盖默认webviewclient类。

I'm making a browser based on android WebView class. I want to enable both horizontal and vertical scrolls on the webview and want it to behave exactly like the android browser? Is there any setting for that in the manifest file or shall i override the default webviewclient class.

推荐答案

的WebView文档说:

在默认情况下,一个web视图不提供类似浏览器的窗口部件

也说:

一个的WebView有几个自定义点,您可以添加自己的行为。它们是:

...

创建和设置WebViewClient子类。当事情发生,影响了内容的呈现,比如,错误或表单提交将被调用。您还可以在这里拦截的URL加载。

Creating and setting a WebViewClient subclass. It will be called when things happen that impact the rendering of the content, eg, errors or form submissions. You can also intercept URL loading here.

这说明 WebViewClient 无关的滚动条,因为他们没有的内容。

Which suggests WebViewClient has nothing to do with the scroll bars, since they're not content.

我要建议把一个的WebView 内部的滚动型,但看的该链接似乎WebView功能的默认行为是有滚动条,这是有道理的,因为大量的滚动条功能的定义高水平查看类。您是否尝试过做一个普通的WebView?如果是这样,你试图加入以下在Java code?

I was going to suggest putting a WebView inside of a ScrollView, but looking at this link it seems WebView's default behaviour is to include scroll bars, which makes sense since a lot of scrollbar functionality is defined in the high level View class. Have you tried just making a regular WebView? If so, have you tried adding the following in your java code?

WebView v = (WebView) findViewById(R.id.webview);
v.setVerticalScrollBarEnabled(true);
v.setHorizontalScrollBarEnabled(true);

这篇关于机器人的WebView滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 18:17