title: MaterialComponents AlertDialog text color
body: <p>Reading <a href="https://stackoverflow.com/questions/52829954/materialcomponents-theme-alert-dialog-buttons">MaterialComponents theme alert dialog buttons</a> and <a href="https://medium.com/@lcdsmao/material-design-custom-alert-dialog-5a9cab3ade11" rel="noreferrer">https://medium.com/@lcdsmao/material-design-custom-alert-dialog-5a9cab3ade11</a> I set <code>AlertDialog</code> buttons and text colors of new Material Theme.</p>
  
  <pre><code>&lt;!-- Base application theme. --&gt;
  &lt;style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar"&gt;
      &lt;!-- Customize your theme here. --&gt;
      &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
      &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
  
      &lt;!-- AlertDialog --&gt;
      &lt;item name="materialAlertDialogBodyTextStyle"&gt;@style/MaterialAlertDialogTextTheme&lt;/item&gt;
      &lt;item name="materialAlertDialogTheme"&gt;@style/MaterialAlertDialogButtonsTheme&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;!-- AlertDialog text --&gt;
  &lt;style name="MaterialAlertDialogTextTheme" parent="MaterialAlertDialog.MaterialComponents.Body.Text"&gt;
      &lt;item name="android:textColor"&gt;@color/colorPrimary&lt;/item&gt;
      &lt;item name="android:colorAccent"&gt;@color/colorPrimary&lt;/item&gt;
      &lt;item name="colorAccent"&gt;@color/colorPrimaryitem&gt;
      &lt;item name="android:textSize"&gt;14sp&lt;/item&gt;
      &lt;item name="android:textStyle"&gt;bold&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;!-- AlertDialog buttons --&gt;
  &lt;style name="MaterialAlertDialogButtonsTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog"&gt;
      &lt;item name="buttonBarPositiveButtonStyle"&gt;@style/AlertDialog.Button&lt;/item&gt;
      ...
  </code></pre>
  
  <p>After creating an <code>AlertDialogFragment</code> using</p>
  
  <pre><code>override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
      super.onCreateDialog(savedInstanceState)
  
      return MaterialAlertDialogBuilder(context!!).apply {
          ...
      }.create()
  }
  </code></pre>
  
  <p>I get</p>
  
  <p><a href="https://i.stack.imgur.com/iKMY1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iKMY1.png" alt="enter image description here"></a></p>
  
  <p>As you see, buttons colors have changed, but <em>text color and style haven't changed</em>.</p>
  
  <p>Then I tried <a href="https://stackoverflow.com/a/51936236/2914140">https://stackoverflow.com/a/51936236/2914140</a>:</p>
  
  <pre><code>&lt;style name="AlertDialog" parent="Base.Theme.AppCompat.Light.Dialog"&gt;
      &lt;item name="android:textColorPrimary"&gt;#005B82&lt;/item&gt;
      &lt;item name="colorAccent"&gt;#1b5e20&lt;/item&gt;
  &lt;/style&gt;
  
  ...
      return MaterialAlertDialogBuilder(context!!, R.style.AlertDialog).apply {
  </code></pre>
  
  <p>and got</p>
  
  <p><a href="https://i.stack.imgur.com/hilMW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hilMW.png" alt="enter image description here"></a></p>
  
  <p>How to do the same without adding <code>AlertDialog</code> theme, only redefining Material theme?</p>