开发者

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

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 solu开发者_StackOverflowtions, 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.


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>

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

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>

<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>
</style>

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!:

https://github.com/android/platform_frameworks_base/tree/master/core/res/res/values


Use this:

parent="Theme.AppCompat.Light.DarkActionBar"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜