使用腾讯TBS x5 浏览器服务 封装常用功能,在使用中如果出现了什么不可预知的错误,可以使用基于原生WebView封装的ZWebView。
- 支持全屏播放视频
- 支持打开网页时进度条
- 支持文件选择
- 支持自动缩放网页
- 支持和网页进行js交互
- 支持H5定位
- 支持加载失败view
app的build.gradle中添加
dependencies {
implementation "com.android.support:appcompat-v7:你的版本号"
implementation 'com.github.zcolin:ZX5WebView:latest.release'
}
工程的build.gradle中添加
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
ZWebView:
webView = (ZX5WebView) findViewById(R.id.webView);
webView.setSupportVideoFullScreen(this) //支持全屏播放视频
.setSupportHorizontalProgressBar()//支持打开网页时顶部带有进度条
.setSupportCircleProgressBar() //支持圆形进度条
.setSupportChooeFile(activity) //支持文件选择
.setSupportAutoZoom() //支持自动缩放网页
.setSupportH5Location() //支持H5定位
.setSupportErrorView() //支持加载失败view
.setSupportJsBridge(); //支持和网页进行js交互(网页端需要的js见app目录下assets/bridgewebview_html_demo)