title: how to programatically theme an activity to be like a dialog?
body: <h1>Question</h1>
  
  <p>How does one programatically (without touching the <code>AndroidManifext.xml</code>) set the theme of an <code>Activity</code> <a href="https://i.imgur.com/jIca2Mq.png" rel="noreferrer">so that it looks like a dialog</a>?</p>
  
  <p>Note: I am ok with modifying the <code>AndroidManifext.xml</code> as long as it does not need to be modified in order to switch between making it look like a normal activity or a dialog.</p>
  
  <h1>What I've tried so far</h1>
  
  <p>I tried the following as per <a href="https://stackoverflow.com/a/22216966/2898715">this stackoverflow answer</a>:</p>
  
  <pre><code>public class DialogActivity extends Activity
  {
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          setTheme(android.R.style.Theme_DeviceDefault_Dialog);
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_dialog);
          Log.d(TAG,"Build.VERSION.SDK_INT: "+Build.VERSION.SDK_INT); // 23
      }
  }
  </code></pre>
  
  <p>But it ends up <a href="https://i.stack.imgur.com/Dh5Kd.png" rel="noreferrer">blacking out everything in the background</a>.</p>
  
  <p>I also saw <a href="https://stackoverflow.com/a/8119116/2898715">this stackoverflow answer</a>, and tried:</p>
  
  <pre><code>public class DialogActivity extends Activity
  {
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          setTheme(android.R.style.Theme_DeviceDefault_Dialog);
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_dialog);
          getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
      }
  }
  </code></pre>
  
  <p>but it ends up making <a href="https://i.stack.imgur.com/MLEWV.jpg" rel="noreferrer">everything black</a>.</p>
  
  <p>What do? Thank you.</p>