How To Add Progress Bar On WebView

How To Add Progress Bar On WebView

How To Add Progress Bar On WebView show that you can show your sites loading progress in your application. Watch the video properly and follow these steps. All the codes can be copy pasted from here.

Watch Video :

httpv://youtu.be//ruoaydkqQl8

XML Codes :

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="?android:attr/progressBarStyle"
android:layout_centerHorizontal="true"
android:id="@+id/prg"/>

Java Codes :

public ProgressBar progressBar;

progressBar = (ProgressBar)findViewById(R.id.prg);

{
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
setTitle("Loading...");
}
@Override public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
setTitle(view.getTitle());
}

}

On our next post we would go through changing the floating button and make it a share option.

6 thoughts on “How To Add Progress Bar On WebView”

  1. I add these codes in android studio, it was working fine but after few hours the circle rotating continuously, it is not stop even after page load, could you help me how to fix it.

    Reply
    • It might be because of the visibility, set the visibility in XML to none then set it to visible in the java section.

      Reply
  2. Hi , I have Made Mobile web view on a template , Could you please teach me how to add progress bar in it and even I have a website that is related to video , Iam not able to see thumbnail on my app, It is just Showing the logo of my app instead of thumbnails ,Iam totally unaware of the coding , Could you please Help ?

    Reply
  3. Hi,
    I have a simple webview and I added your code but the things is not happening.Can you help me.I am already joined in the said group.

    Thanks
    Nitu Kumar

    Reply

Leave a Comment