title: How to make the switch button center in dialog
body: <p>I want to switch button center in dialog,but it's failed...</p>
  
  <p>Why is this?</p>
  
  <pre><code>Switch sw = new Switch(MainActivity.this);
  sw.setTextOn("start");
  sw.setTextOff("close");
  sw.setGravity(Gravity.CENTER_HORIZONTAL);
  
  AlertDialog.Builder myDialog = new AlertDialog.Builder(MainActivity.this);
  myDialog.setTitle("title");
  myDialog.setMessage("message");
  myDialog.setView(sw);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Dfxar.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dfxar.jpg" alt="enter image description here"></a></p>