Home » Android » android – Setting Application theme textColor to white causes Context Menu item text to be white (invisible)

android – Setting Application theme textColor to white causes Context Menu item text to be white (invisible)

Posted by: admin May 14, 2020 Leave a comment


Ok, this is driving me bonkers. To skin my app, I set the following in my theme:

<item name="android:textColor">#FFFFFF</item>

All the text in the app turns white, unless I manually override it in the layout xmls. Great, yay, easy peasy. EXCEPT that the text in my menu options for context menus (off of lists and such) have also decided to become white.

This is not so great, since it is hard to read white on white. I have tried a variety of solutions, including searching for how to change the text color of a context menu (no dice)and creating a textAppearance item in my theme. The last solution didn’t change all the textfields in my app, which was frustrating.

So, any suggestions? Hopefully my dilema is clear.

How to&Answers:

In your styles.xml try overriding the textViewStyle instead of just ALL textColor attributes:

<style name="Theme.Blundell.Light" parent="@android:style/Theme.NoTitleBar">
    <item name="android:windowBackground">@drawable/background_light</item>
    <item name="android:textViewStyle">@style/Widget.TextView.Black</item>

<style name="Widget.TextView.Black" parent="@android:style/Widget.TextView">
    <item name="android:textColor">#000000</item>

You could even take it one further and just override the color for a certain view, like buttons:

<style name="Widget.Holo.Button" parent="@android:style/Widget.Holo.Button">
    <item name="android:textColor">#FFFFFF</item>

<style name="Theme.Blundell" parent="@android:style/Theme.Holo.NoActionBar">
    <item name="android:colorBackground">@android:color/transparent</item>
    <item name="android:buttonStyle">@style/Widget.Holo.Button</item>

If your inspired to do any more theming check out the Android source it’s the best place to realise what you can and can’t do!:



Use this: