webview最全面详解(一)了解官方文档,androidstudio开发实战pdf

WebView是手机中内置了一款高性能 webkit 内核浏览器,在 SDK 中封装的一个组件。没有提供地址栏和导航栏,WebView只是单纯的展示一个网页界面。在开发中经常都会用到。

显示和渲染Web页面

直接使用html文件(网络上或本地assets中)作布局

可和JavaScript交互调用

WebView控件功能强大,除了具有一般View的属性和设置外,还可以对url请求、页面加载、渲染、页面交互进行强大的处理。

本文翻译官方文档认识和了解webview。

翻译

官方文档 (自备梯子)

这里写图片描述

A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

一个用来展示网页的view控件,在这个类的基础上,你可以在你的activity中使用系统自带浏览器或者简单的展示一些在线的内容。

Note that, in order for your Activity to access the Internet and load web pages in a WebView, you must add the INTERNET permissions to your Android Manifest file:

请注意,为了让您的Activity能访问网络并在WebView中加载网页,您必须将INTERNET权限添加到您的Android Manifest文件中:

This must be a child of the element.

For more information, read Building Web Apps in WebView.

这条必须作为 元素的子标签。

更多信息请阅读用WebView构建 Web应用程序

Basic usage


By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored. If your goal is only to display some HTML as a part of your UI, this is probably fine; the user won’t need to interact with the web page beyond reading it, and the web page won’t need to interact with the user. If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView. For example:

默认情况下,webview并不提供类似浏览器的不见,不支持JavaScript 并且忽略网页错误。如果你的目的是仅仅显示一些HTML作为你的UI的一部分,那可能不错,用户阅读网页而不需要与之交互,网页也不需要和用户交互。

如果你真的想要一个完整的Web浏览器,那你可能需要通过一个URL intent调用浏览器应用程序而不是在WebView中显示它,

例如:

Uri uri &#

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值