制作的WebView自动链接可见 [英] Make Webview's auto links visible

查看:230
本文介绍了制作的WebView自动链接可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网页视图将显示在内容HTML链接具有蓝色下划线。所以,如果你在HTML类似

A Webview will display links in the content HTML as having blue underlines. So if you have something in the HTML like

<a href="...">blah blah</a>

...它是作为一个链接清晰可见。

... it is clearly visible as a link.

web视图,您还可以点击电话号码和地址(即使是那些在HTML只是文本,而不是链接)来启动拨号器或地图。

The Webview also allows you to click on phone numbers and addresses (even if those are just text in the HTML, not links) to launch the Dialer or Maps.

如何能一赠网页视图显示这些(Linkify,可能)用下划线等链接?这是在一个TextView很容易,因为人们可以从一个TextView获得跨度和他们的风格,但网页视图不公开任何方式检索数据......至少不是我能看到翻翻文档。

How can one get Webview to display those (Linkify, probably) links with underlines etc? It's easy enough in a TextView since one can get the spans from a TextView and style them, but Webview doesn't expose any way to retrieve that data... at least not that I can see looking through the docs.

推荐答案

有鉴于此:

  • http://code.google.com/p/android/issues/detail?id=742

它仍然似乎不是一种方法来直接从Java做到这一点。可能工作的一件事就是写一些JavaScript code和页面加载后运行它,例如这里给出:

it still doesn't seem to be a way to do this from Java directly. One thing that might work is to write some JavaScript code and run it after page is loaded, e.g. as given here:

  • In Android Webview, am I able to modify a webpage's DOM?

下面是一个类似的事情的例子:

Here's an example of a similar thing:

  • Disabling links in android WebView

的想法是禁用的链接。您可能能够使用类似的方法来添加一些CSS,包括下划线。一对夫妇的其他SOqs /链接,可以帮助:

where the idea is to disable links. You may be able to use a similar approach to add some CSS, including underlining. A couple of other SOqs / links that might help:

  • Android: Injecting Javascript into a Webview outside the onPageFinished Event
  • Android: Injecting Javascript into a Webview outside the onPageFinished Event
  • http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview
  • Injecting Javascript into a Webview outside the onPageFinished Event (Using DatePicker to set a date on an input of a WebView)

希望这有助于。

这篇关于制作的WebView自动链接可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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