1

My loading circle works fine but has a white box behind it as seen here. I have spent a few hours searching for solutions and all of the SO posts I've found suggest an implementation very similar to the one I've used. I also tried applying a custom theme to the dialog and setting transparency but this did nothing. I'm not sure what the white rectangle actually is since changing the properties of the ProgressBar itself only seems to affect the square in the center containing the image.

I have the following layout defined for my progress bar which runs during my AsyncTask.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@android:color/transparent" >

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"/>

</FrameLayout>

Below is my method for the dialog which uses the layout shown above.

    public static ProgressDialog createProgressDialog(Context mContext) {
        ProgressDialog dialog = new ProgressDialog(mContext);
        try {
            dialog.show();
        } catch (WindowManager.BadTokenException e) {

        }
        dialog.setCancelable(false);
        dialog.setContentView(R.layout.progressdialog);
        return dialog;
    }

    public class FetchAcroTask extends AsyncTask<String, Void, String[]> {

        Dialog progressDialog = null;

        @Override
        protected void onPreExecute() {

            // Display loading circle
            if (progressDialog == null) {
                progressDialog = createProgressDialog(AcroActivity.this);
                progressDialog.show();
            } else {
                progressDialog.show();
            }
        }

        @Override
        protected String[] doInBackground(String... params) {

            if (params.length == 0) {
                return null;
            }
            return GET(params[0]);
        }

        @Override
        protected void onPostExecute(String[] resultStrs) {

            if (resultStrs == null) {
                acroAdapter.add("No results were found");
            } else {
                acroAdapter.addAll(resultStrs);
            }

            // Dismiss loading circle
            progressDialog.dismiss();

        }
    }
}

Thanks in advance.

BSavaliya
  • 809
  • 1
  • 16
  • 26
Ali Hirani
  • 191
  • 1
  • 8
  • you are creating an Actuall progress dialog. You have to use the ProgressBar. Find its view by its id and then Show it or dismiss it.... –  Mar 01 '15 at 23:02
  • You need to make your dialog transparent http://stackoverflow.com/questions/10795078/dialog-with-transparent-background-in-android – tachyonflux Mar 01 '15 at 23:04

1 Answers1

0

I've found the solution thanks to the comment left by Kostas.

I transferred my ProgressBar declaration to my layout file for the activity and simply hide it when my AsyncTask is complete.

In my activity's layout file:

<ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true" />

Within the async task:

    @Override
    protected void onPostExecute(String[] resultStrs) {

        if (resultStrs == null) {
            acroAdapter.add("No results were found");
        } else {
            acroAdapter.addAll(resultStrs);
        }

        // Dismiss loading circle
        progressBar = (ProgressBar) findViewById(R.id.progressBar1);
        progressBar.setVisibility(View.INVISIBLE);
    }

Thank you.

Ali Hirani
  • 191
  • 1
  • 8