这个功能对于展示app的使用帮助是很有帮助的
核心代码:private void initView() {
mWebView = (WebView) findViewById(R.id.load_webView);
mProgressBar = (ProgressBar) findViewById(R.id.load_progressBar);
mLoadingLayout = (RelativeLayout) findViewById(R.id.loading_layout);
mPrompt = (TextView) findViewById(R.id.prompt);
mNoInternetImageView = (ImageView) findViewById(R.id.no_internet_img);
WebSettings webSettings = mWebView.getSettings();
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webSettings.setJavaScriptEnabled(true);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setUseWideViewPort(true);
// webSettings.setBuiltInZoomControls(true);
mWebView.requestFocus();
mWebView.loadUrl("file:///android_asset/software_licenses.html");
initWebViewListener();
}
private void initWebViewListener() {
// this.mWebView.setWebViewClient(new WebViewClient() {
// });
this.mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress >= 80) {
mWebView.setVisibility(View.VISIBLE);
}
}
});
}
本地的html文件是:<?xml version="1.0" encoding="UTF-8"?>
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Software License.box { overflow:hidden; width:96%; margin: 0 auto; padding-top: 20px;}
.lan { overflow:hidden; margin-bottom:20px; color:#2f2f2f; background-color:#eee;}
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote {
margin: 0;
padding: 0;
text-align: left;
}
body {
font-family: sans, Arial, sans-serif;
font-size: 13px;
line-height: 18px;
color: #2f2f2f;
background-color: white;
margin:0;
padding: 0;
text-align: center;
}
a {
color: #0069d6;
}
a:hover {
color: #0050a3;
text-decoration: none;
}
a img {
border: none;
}
p {
overflow:hidden;
padding:10px 0 0 10px;
margin-bottom: 9px;
}
h1 {
margin-bottom: 18px;
font-size: 18pt;
text-decoration:underline;
}
h2 {
font-size: 24px;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 20px;
}
h5 {
font-size: 14px;
}
h6 {
font-size: 13px;
}
hr {
margin: 0 0 19px;
border: 0;
border-bottom: 1px solid #ccc;
}
ol, ul { margin:0 10px 0 0; text-align: left;}
li { text-align: left;}
/*
@media screen and (min-width: 914px) {
body {
width: 854px;
margin:10px auto;
}
}
@media print {
body,code,pre code,h1,h2,h3,h4,h5,h6 {
color: black;
}
table, pre {
page-break-inside: avoid;
}
}
*/
apache-mime4j
Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
for the specific language governing permissions and limitations under the License.
bcprov-jdk15on
Copyright © 2000 - 2013 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of
the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.