更新时间:2022-03-21 03:45:19
以及用于水平式的,我想你首先需要定义你的进度条,并与您的XML文件中像这样联系起来:
well for horizontal style, I guess you first need to define your progress bar and link it with your xml file like this:
final ProgressBar Pbar;
final TextView txtview = (TextView)findViewById(R.id.tV1);
Pbar = (ProgressBar) findViewById(R.id.pB1);
然后,你可以使用onProgressChanged方法在WebChromeClient:
Then, you may use onProgressChanged Method in your WebChromeClient:
MyView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
if(progress < 100 && Pbar.getVisibility() == ProgressBar.GONE){
Pbar.setVisibility(ProgressBar.VISIBLE);
txtview.setVisibility(View.VISIBLE);
}
Pbar.setProgress(progress);
if(progress == 100) {
Pbar.setVisibility(ProgressBar.GONE);
txtview.setVisibility(View.GONE);
}
}
});
在这之后,你的布局,你有这样的事情
After that, in your layout you have something like this
<TextView android:text="Loading, please wait . . ."
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/tV1" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#000000"></TextView>
<ProgressBar android:id="@+id/pB1"
style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_centerVertical="true"
android:padding="2dip">
</ProgressBar>
这是我做到了我的应用程序。我想这样做在使用progressbarLarge以不同的方式,但我不能,因为我失去了一些东西在那里,我不知道。我会很高兴,如果有人在分享他们是如何做到这在progressbarLarge一个web视图中的任何想法。
This is how i did it in my app. i was thinking of doing it in a different way using progressbarLarge but i couldn't because i was missing something there i don't know. I would be happy if someone shares any ideas on how they did this on progressbarLarge inside a webView.