How do I change the textColorPrimary in a theme?

后端 未结 3 2374
借酒劲吻你
借酒劲吻你 2021-02-20 16:21

I\'m changing the theme of an activity in onCreate using setTheme (I\'m doing that even before calling super.onCreate(), as this is supposed to be more reliable).

It doe

相关标签:
3条回答
  • 2021-02-20 17:02

    Just as a workaround, Instead of using textAppearanceLarge in the layout, (if you're using xml to build the layout), define your own textAppearanceLarge style in the styles.xml that emulates the android default one except you can change the color to white.

    xml layout:

    <!-- example textview -->
    <TextView style="@style/large" android:text="text goes here"></TextView>
    

    then in the styles.xml

    <style name="large">
        <item name="android:textColor">@android:color/white</item>
        <!-- other necessary items here like font etc.-->
    </style>
    
    0 讨论(0)
  • 2021-02-20 17:02

    The only difference between "style" and "theme" is the scope at which a style is applied at. A style applied to an Activity is called a Theme.

    Here's a good writeup on the topic : http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/

    0 讨论(0)
  • 2021-02-20 17:10

    Turns out I was barking up the wrong tree. Overriding the colors and everything worked just fine. However, by defining android:background in my theme, everything just completely messed up, and all text appeared white, despite me overriding all colors (including textColorPrimary). Omitting android:background did the trick.

    0 讨论(0)
提交回复
热议问题