Note that there are some explanatory texts on larger screens.

plurals
  1. POAlertDialog styling - how to change style (color) of title, message, etc
    primarykey
    data
    text
    <p>I've breaking my head over this quite a bit. What I need to do is, change the style of all <code>AlertDialog</code>s in my android application - dialog background needs to be white-ish, and text needs to be black-ish. I tried creating a lot of styles, themes, and applying from the code, manifest, etc, but no success, with regard to the text colors inside the <code>AlertDialog</code>. Right now, I have the simplest of codes, set like this:</p> <p>Manifest:</p> <blockquote> <pre><code>&lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; </code></pre> </blockquote> <p>styles.xml:</p> <blockquote> <pre><code>&lt;style name="AppTheme" parent="AppBaseTheme"&gt; &lt;item name="android:alertDialogStyle"&gt;@style/DialogStyle&lt;/item&gt; &lt;/style&gt; &lt;style name="DialogStyle" parent="@android:style/Theme.Dialog"&gt; &lt;!-- changing these background stuff works fine --&gt; &lt;item name="android:bottomBright"&gt;@android:color/white&lt;/item&gt; &lt;item name="android:bottomDark"&gt;@android:color/white&lt;/item&gt; &lt;item name="android:bottomMedium"&gt;@drawable/dialog_footer_bg&lt;/item&gt; &lt;item name="android:centerBright"&gt;@android:color/white&lt;/item&gt; &lt;item name="android:centerDark"&gt;@drawable/dialog_body_bg&lt;/item&gt; &lt;item name="android:centerMedium"&gt;@android:color/white&lt;/item&gt; &lt;item name="android:fullBright"&gt;@color/orange&lt;/item&gt; &lt;item name="android:fullDark"&gt;@color/orange&lt;/item&gt; &lt;item name="android:topBright"&gt;@color/green&lt;/item&gt; &lt;item name="android:topDark"&gt;@drawable/dialog_header_bg&lt;/item&gt; </code></pre> </blockquote> <p>The items listed below don't work (please read the comments I've put above each element):</p> <blockquote> <pre><code> &lt;!-- panelBackground is not getting set to null, there is something squarish around it --&gt; &lt;item name="android:panelBackground"&gt;@null&lt;/item&gt; &lt;!-- Setting this textColor doesn't seem to have any effect at all. Messages, title, button text color, whatever; nothing changes. --&gt; &lt;item name="android:textColor"&gt;#000000&lt;/item&gt; &lt;!-- Also tried with textAppearance, as follows. Didn't work --&gt; &lt;item name="android:textAppearance"&gt;?android:attr/textColorPrimaryInverse&lt;/item&gt; &lt;!-- Also tried changing textAppearancePrimary, to no avail --&gt; &lt;item name="android:textColorPrimary"&gt;#000000&lt;/item&gt; &lt;!-- Also need to change the dialog title text, tried it as follows, dint work: --&gt; &lt;item name="android:windowTitleStyle"&gt;@style/DialogWindowTitle&lt;/item&gt; &lt;/style&gt; </code></pre> </blockquote> <p>The DialogWindowTitle is defined as follows:</p> <blockquote> <pre><code>&lt;style name="DialogWindowTitle"&gt; &lt;item name="android:textAppearance"&gt;?android:attr/textAppearanceMediumInverse&lt;/item&gt; &lt;/style&gt; </code></pre> </blockquote> <p>So none of these is working. Can anyone tell me what I could be doing wrong, and how can I:</p> <ol> <li>Change text color for messages (content text)</li> <li>Change title text color </li> <li>Remove the panel background</li> </ol> <p>Note: I need to support API 8 (2.2) upwards. Also, I've went through most of the related question here, and google groups, but can't figure out, though I have a feeling its right under my nose!</p> <p>Edit: adding screenshot:</p> <p><img src="https://i.stack.imgur.com/4ArTR.png" alt="AlertDialog not themed as expected"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload