I have a custom dialog (inherited from android.app.Dialog
) with no title or border. To this dialog I add a normal ProgressBar
, and would like to center it in the dialog. The dialog itself has a background image that stretches for the full screen. Everything seems to work except that the progress bar is not getting centered in the dialog. It looks like this:
This is the code I have used within the customDialog class, to add the progress bar to the dialog:
ProgressBar progBar = new ProgressBar(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
addContentView(progBar, layoutParams);
getWindow().setGravity(Gravity.CENTER);
Is there something I'm missing, or getting wrong?