一个轻量级的库,加载html效果很好,而且功能很强大。那就是AgentWeb
GitHub地址:https://github.com/Justson/AgentWeb
GitHub上面介绍:
AgentWeb 是一个基于的 Android WebView ,极度容易使用以及功能强大的库,提供了 Android WebView 一系列的问题解决方案 ,并且轻量和极度灵活,体验请下载的 agentweb.apk, 或者你也可以到 Google Play 里面下载 AgentWeb , 详细使用请参照上面的 Sample 。
引入:
api 'com.just.agentweb:agentweb:4.1.2' // (必选)
api 'com.just.agentweb:filechooser:4.1.2'// (可选)
api 'com.download.library:Downloader:4.1.2'// (可选)
我没有用下载功能,就只引用上面两个。
最基础的使用:
mAgentWeb = AgentWeb.with(this).setAgentWebParent(layout, new LinearLayout.LayoutParams(-1, -1))
.useDefaultIndicator().createAgentWeb().ready().go("https://www.jd.com");
销毁:
@Override
protected void onPause() {
super.onPause();
if (mAgentWeb != null) {
mAgentWeb.getWebLifeCycle().onDestroy();
}
}
@Override
protected void onResume() {
super.onResume();
if (mAgentWeb != null) {
mAgentWeb.getWebLifeCycle().onResume();
}
}
这是我用到最基础的用法,详细用法以及介绍参考https://github.com/Justson/AgentWeb