title: Apply similar looking styles to AlertDialog box for different Android versions
body: <p>I want to make the AlertDialog box for my app look like the ones on Android > 6.0.0 ( as depicted in the following screenshots) for all lower android version till 4.4.4. I have applied a custom style for the dialog box. </p>
  
  <p>Following is the style in styles.xml for AlertDialog:</p>
  
  <pre><code>&lt;style 
      name="AlertDialogCustom" parent="ThemeOverlay.AppCompat.Dialog.Alert"&gt;
      &lt;item name="android:textColor"&gt;@color/blue&lt;/item&gt;
      &lt;item name="android:textColorSecondary"&gt;@color/white&lt;/item&gt;
      &lt;item name="android:textColorPrimary"&gt;@color/white&lt;/item&gt;
      &lt;item name="android:background"&gt;@color/dark_grey&lt;/item&gt;
      &lt;item name="android:backgroundDimAmount"&gt;0.3&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>Following is how I applied the style in java:</p>
  
  <pre><code>new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AlertDialogCustom))
              .setMessage("Why is DialogBox Style Inconsistent through different android versions?")
  
              // Specifying a listener allows you to take an action before dismissing the dialog.
              // The dialog is automatically dismissed when a dialog button is clicked.
              .setPositiveButton("Yes", new DialogInterface.OnClickListener()
              {
                  public void onClick(DialogInterface dialog, int which)
                  {
                      //Do Something
                  }
              })
  
              .setNegativeButton("No", new DialogInterface.OnClickListener()
              {
                  public void onClick(DialogInterface dialog, int which)
                  {
                      //Do Something
                  }
              })
              .show();
  </code></pre>
  
  <p>As a get around I managed to at least change the text color to white on the dark background by using:</p>
  
  <pre><code>    if (android.os.Build.VERSION.SDK_INT &lt;= Build.VERSION_CODES.LOLLIPOP_MR1)
          style = android.R.style.Theme_Material_Dialog;
  
      else
          style = R.style.AlertDialogCustom;
  </code></pre>
  
  <p><strong>So far I have tried</strong> making seperate style for lower Android version and apply them via java by detecting Android version. But, I am unable to replicate the style of AlertDialog box on Android 6+ on lower android versions till 4.4.4. And I am unable to find a solution on the internet.</p>
  
  <p>There is an anomaly though; if I apply my custom style on Rate this app provided by <a href="https://github.com/kobakei/Android-RateThisApp" rel="nofollow noreferrer">kobakei</a> the resulting RateThisApp dialog looks the same on all the android versions. So I believe styling the AlertDialog in a particular manner should fix the issue.</p>
  
  <p><strong>This is what I want - To make the AlertDialog box on Android 4.4.4 and 5.1.0 to look like the one in Android 6.0.0 and higher by using suitable styles. And why does the textColor and textColorPrimary attributes does not get applied on lower android versions?</strong></p>
  
  <p>If the resource provided in my question is insufficient please let me know in the comment, I will share more details.</p>
  
  <p>Here are the screenshots of AlertDialog box on different Android versions with the same style applied.</p>
  
  <ul>
  <li>Android >= 6.0.0</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/qFZAo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qFZAo.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>Android = 5.1.0</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/pOuQg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pOuQg.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>Android 4.4.4</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/eVTXk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eVTXk.png" alt="enter image description here"></a></p>