Reputation: 6108
I am customizing my android app by defining theme in styles.xml
. I would like to apply a basic text color to all text of my app, but I want to keep the appearance of AlertDialog
as default (Holo.Light).
styles.xml
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:textColor">@android:color/holo_red_dark</item>
<item name="android:alertDialogTheme">@style/AlertDialogStyle</item>
</style>
<style name="AlertDialogStyle" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@style/DialogWindowTitle</item>
</style>
<style name="DialogWindowTitle">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">@style/DialogWindowTitleAppearance</item>
</style>
<style name="DialogWindowTitleAppearance" parent="@android:style/TextAppearance.Holo.DialogWindowTitle">
<item name="android:textColor">@android:color/holo_purple</item>
</style>
</resources>
However, the color defined in AppTheme
overrides the purple color:
If I remove the line <item name="android:textColor">@android:color/holo_red_dark</item>
in AppTheme
, the text color of the title changes correctly.
So my question is: How can I define a text color for my app theme, while setting another color (or preserving system default color) to the dialog title text?
Upvotes: 2
Views: 3013
Reputation: 4844
define
<item name="android:textAppearanceLarge">...</item>
in your AlertDialogStyle
Upvotes: 1
Reputation: 31
Great work with drilling down to the specific text you want to change. The fact it isn't working looks like a bug to me. If you want a built-in alert dialog window instead of a custom themed one, you can use this function when you build an alert box:
AlertDialog.Builder(Context context, int theme)
"theme" can be AlertDialog.ThemeTraditional or some other AlertDialog theme constant. I imagine you've moved on by now, maybe making your own alert dialog activity to replace it, but the above was an adequate workaround for me (I had white text on light grey background, so I had to do something).
Upvotes: 0
Reputation: 76
in Your AndroidManifest.xml set another style to your Activity
<activity
android:name="com.my.sample.Activity"
android:theme="@android:style/Theme.Holo.Light.Dialog"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/my_activity_name">
</activity>
Upvotes: 0