0

Question in the title) Help me, please) I want to make from this enter image description here

that

enter image description here

I tried implement it's.

mProgressDialog = new ProgressDialog(this);
mProgressDialog.getWindow().setContentView(R.layout.footcloth);
mProgressDialog.setMessage(Constants.PROGRESS_DIALOG_MESSAGE);
mProgressDialog.show();

But this code throwing exception

java.lang.RuntimeException: Unable to start activity ComponentInfo{im.anticafe.anticafeim/im.anticafe.anticafeim.activities.HomeActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

This code implements in activity BottomBarActivity

abstract public class BottomBarActivity extends AppCompatActivity implements View.OnClickListener {

    private static final String TAG = "bottomBarActivity";
    private int mWidth;
    private ProgressDialog mProgressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.getWindow().setContentView(R.layout.footcloth);
        mProgressDialog.setMessage(Constants.PROGRESS_DIALOG_MESSAGE);
        mProgressDialog.show();
        ...
    }

    ...
}

And this activity are extending in others. So, help me solve my problem, please) Thanks)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Scrobot
  • 1,911
  • 3
  • 19
  • 36

1 Answers1

7

There are 2 answers

  1. If you wanna change color ( transparency ) of background under Progress dialog,I recommend you to use fragments and switch them. At fragment you can set any properties and put ProgressBar

after complete reload, you can switch back again, or to another fragment

  1. If you wanna change progress dialog

    public class TransparentProgressDialog extends Dialog {
    
      public TransparentProgressDialog(Context context) {
        super(context, R.style.TransparentProgressDialog);
    
        WindowManager.LayoutParams wlmp = getWindow().getAttributes();
    
        wlmp.gravity = Gravity.CENTER_HORIZONTAL;
        getWindow().setAttributes(wlmp);
        setTitle(null);
        setCancelable(false);
        setOnCancelListener(null);
        View view = LayoutInflater.from(context).inflate(
                R.layout.progress_dialog, null);
        setContentView(view);
       }
    }
    

In your activity use

TransparentProgressDialog pd = new TransparentProgressDialog(context);
pd.show();

....

if (pd.isShowing()){
            pd.dismiss();
        }
koa73
  • 861
  • 2
  • 10
  • 27
  • it's good also i use custom style to set it match parent , like bellow ` ` and then call it in constructor like here ` public TransparentProgressDialog(Context context , R.style.My_Dialog)` – Marjan Davodinejad Aug 13 '18 at 13:38