androidbackgroundprogressdialog

Custom background color for a ProgressDialog


I have a progressDialog, that works, but doesn't fit my extetical needs:

enter image description here

I'd like to make it like this:

enter image description here

What I tried:

1 - Theming (with both a style only and a style + theme methods), as explained here
The result was AWFUL (I got an extra border around the dialog in the same blue color and an extra padding around the title with that default grayish color)

In other words, i got somethig like this:

enter image description here

2 - Extending the ProgressDialog Class and giving it a custom layout, without any success

I got a bunch of different errors and I made a big mess trying to fix this one, this other one, ... no way!!

Now, i know that someone has done it before... Show me the light, please!!

Some code, to show you how I make it actually

In declarations I have:

ProgressDialog pbrDlg = null;

Then in a menu selection I have:

case R.id.mnuBack:
case R.id.mnuRest:
{
    // Backup or Restore
    // Instantiate a new progress dialog
    pbrDlg = new ProgressDialog(ACT_Base.this);

    // Spinner (wheel) style dialog
    pbrDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    String str = "";
    if (itm.getItemId() == R.id.mnuBack)
    {
        pbrDlg.setIcon(android.R.drawable.ic_menu_save);
        pbrDlg.setTitle(getString(R.string.data_save));
        str = "save";
    }
    else
    {
        pbrDlg.setIcon(android.R.drawable.ic_menu_revert);
        pbrDlg.setTitle(getString(R.string.data_load));
        str = "load";
    }
    pbrDlg.setMessage(getString(R.string.data_msg));

    // Display the dialog
    pbrDlg.show();

    // Start the async task
    new Data_ImpEx_Task(str).execute();

    break;
}

Solution

  • I have finally succeeded in solving my problem.

    I used a DialogFragment which I customized in each part to make it look like a ProgressDialog.

    After all, I am doing the same for showing Alerts and Confirmations, so...

    This is the result I got:

    enter image description here

    I just have to virate the icon to a blueish flavour and it's nearly perfect.