I am using the following code to add a progress dialog:
progress_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:windowIsFloating="false"
android:background="@android:color/white">
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true" />
</RelativeLayout>
MainActivity.java
public void onProgressChanged(WebView view, int progress) {
if (mProgress == null) {
mProgress = new ProgressDialog(MainActivity.this);
// Setting progress dialog color as transparent
mProgress.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
mProgress.show();
mProgress.setContentView(R.layout.progress_dialog);
mProgress.setCancelable(false);
mProgress.setCanceledOnTouchOutside(false);
// Added to prevent touch interaction while loading
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
// WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
}
// Setting text on progress bar
// mProgress.setMessage("Loading " + String.valueOf(progress) + "%");
if (progress == 100) {
mProgress.dismiss();
mProgress = null;
// Resume touch interaction once loaded
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
}
}
This shows the progress dialog as seen below:
I want the progress dialog to cover the entire screen as seen below:
How to accomplish this with ProgressDialog?

