我在 webview 上方添加了进度条。每当我点击一个链接时,我只是让进度条可见。
我想在 webview 上叠加进度条,我想显示进度条的百分比。我知道css,但我不知道如何改变android中进度条的位置
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
MainActivity.java
public class MainActivity extends Activity {
WebView web;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.webview01);
// request the progress-bar feature for the activity
getWindow().requestFeature(Window.FEATURE_PROGRESS);
// set a webChromeClient to track progress
web.setWebChromeClient(new WebChromeClient()
{
public void onProgressChanged(WebView view, int progress)
{
// update the progressBar
MainActivity.this.setProgress(progress * 100);
}
});
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("url");
}
// To handle "Back" key press event for WebView to go back to previous screen.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK) && web.canGoBack()) {
web.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
要显示进度条百分比,我需要修改此代码吗?或者我可以从这段代码中扩展功能吗?