title: Android: How to display full screen progress bar in center
body: <p>I am trying to display progress bar with custom theme. But it is coming in top left corner instead of center. If I don't use custom theme it will come in center but not full screen, which displays textviews and other elements in background which looks bad. The following is the code and screenshot</p>
  
  <p>Custom Theme:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ProgressBar
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In activity initialising progress dialog with custom theme:</p>
  
  <pre><code>progressBar = new ProgressDialog(context, R.layout.layout_progress_dialog);
  progressBar.setMessage("Please wait...");
  progressBar.setCancelable(false);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hrDam.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hrDam.png" alt="enter image description here"></a></p>
  
  <p>When I see the preview of progress bar theme alone it shows correctly as below. But in activity it shows in wrong position.</p>
  
  <p><a href="https://i.stack.imgur.com/Glt1k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Glt1k.png" alt="enter image description here"></a></p>