Te dejo mi ejemplo.
Tienes que definir el pogressbar en mi caso un progressWheel en el toolar, asi:
<LinearLayout
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progress1"
android:layout_width="35dp"
android:layout_height="35dp"
app:matProg_progressIndeterminate="true"
app:matProg_barColor="@android:color/white"
android:visibility="gone"/><!-- gone -->
</LinearLayout>
Y la activity volverá visible o invisible(gone) si el sitio esta cargando
package cl.ejemplo.sitioweb.fragmentos;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import com.pnikosis.materialishprogress.ProgressWheel;
import cl.ejemplo.sitioweb.R;
import cl.ejemplo.sitioweb.actividades.Root; //activity que contiene al fragment
import cl.ejemplo.sitioweb.utilidades.Datos;
public class ejemploWeb extends Fragment {
private final static String TAG = ">>> ejemploWeb";
public Root fragmentActivity;
private ProgressWheel progressPw;
private WebView intranetWv;
private MenuItem actualizar;
//private Menu menu;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fragmentActivity = (Root) super.getActivity();
final LinearLayout myLinearLayout = (LinearLayout) inflater.inflate(R.layout.fragment_intranet, container, false);
Log.d(">>>", TAG);
Toolbar toolbar = (Toolbar) fragmentActivity.findViewById(R.id.toolbar);
progressPw = (ProgressWheel) toolbar.findViewById(R.id.progress1);
intranetWv = (WebView) myLinearLayout.findViewById(R.id.intranet_wv);
intranetWv.getSettings().setJavaScriptEnabled(true); //Funciona con JS el sitio
intranetWv.getSettings().setDomStorageEnabled(true);
intranetWv.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
try{
//Log.d(TAG, "onPageStarted >>> " + url);
super.onPageStarted(view, url, favicon);
if (url != null && url.substring(url.length()-5).toLowerCase().contains(".pdf") && !url.toLowerCase().contains("docs.google.com")) {
intranetWv.loadUrl("https://docs.google.com/gview?embedded=true&url=" + url);
//https://docs.google.com/viewer?url=
}
else if (url != null && url.substring(url.length()-5).toLowerCase().contains(".xls") && !url.toLowerCase().contains("drive.google.com")) {
intranetWv.loadUrl("https://drive.google.com/viewerng/viewer?embedded=true&url=" + url);
}
progressPw.setVisibility(View.VISIBLE);
actualizar.setVisible(false);
}
catch(Exception e){
//e.printStackTrace();
}
}
@Override
public void onPageFinished(WebView view, String url) {
//Log.d(TAG, "onPageFinished >>> " + url);
try {
progressPw.setVisibility(View.GONE); //GONE
actualizar.setVisible(true);
}catch (Exception e){
//e.printStackTrace();
}
}
public boolean shouldOverrideUrlLoading(WebView view,String url) {
if (url.startsWith("mailto:")) {
try{
Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse(url));
startActivity(i);
}catch (Exception e){
e.printStackTrace();
}
} else if (!url.contains("ejemplo.cl")) { //Si no esta en la intranet, abre el navegador
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} else {
view.loadUrl(url);
}
return true;
}
});
if (Build.VERSION.SDK_INT >= 21) {
intranetWv.getSettings().setMixedContentMode( WebSettings.MIXED_CONTENT_ALWAYS_ALLOW );
}
//Permite Zoom en la WebView y ocultamos botones
intranetWv.setInitialScale(150);
intranetWv.getSettings().setBuiltInZoomControls(true);
intranetWv.getSettings().setSupportZoom(true);
intranetWv.getSettings().setDisplayZoomControls(false);
intranetWv.loadUrl(getString(R.string.url_intranet));
intranetWv.clearCache(true);
//Poder usar el botón volver del celular en el fragment
final Handler handler = new Handler(){
@Override
public void handleMessage(Message message) {
switch (message.what) {
case 1:{
intranetWv.goBack();
}break;
}
}
};
intranetWv.setOnKeyListener(new View.OnKeyListener(){
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == MotionEvent.ACTION_UP && intranetWv.canGoBack()) {
handler.sendEmptyMessage(1);
return true;
}
return false;
}
});
return myLinearLayout;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // super para el menú
setHasOptionsMenu(true); // que tenga opciones el menú
}
@Override
public void onStop() {
super.onStop(); // super para el menú
progressPw.setVisibility(View.GONE); //GONE
}
//Definimos que iconos del menu accionan como se hace normalmente en onOptionsItemSelected y onCreateOptionsMenu //definimos el menuItem
public void onPrepareOptionsMenu(Menu menu){
menu.clear();
Toolbar toolbar= (Toolbar) getActivity().findViewById(R.id.toolbar);
toolbar.inflateMenu(R.menu.menu_intranet);
actualizar = toolbar.getMenu().findItem(R.id.actualizar_intranet_item);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.actualizar_intranet_item:
Log.d(TAG, "Reload");
intranetWv.reload();
return true;
default:
return false;
}
}
});
}
}