I have an app which is using a black background. I've been developing and testing it on Lollipop, yet minSDK is 19. When I use a KitKat device (or emulator), I run into a problem with the white text I see on my Lollipop device - it is black and thus invisible.
I define the text color like this:
<TextView
android:id="@+id/list_header_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:text="27.02.2016"
android:textColor="@color/text_primary"
android:textSize="16dp"/>
Then, in (all) my styles.xml I have the following theme defined:
<style name="AppTheme.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:background">@color/colorPrimary</item>
</style>
In colors.xml, text_primary
is defined like this:
<color name="text_primary">#FFFFFF</color>
Once again, on Lollipop I can see the text in pure perfect white, yet on KitKat it appears black. Where did I go wrong? In my opinion, since the TextView
textcolor is defined explicitly to be text_primary
it should work on across all SDK versions?!
Thanks to @zgc7009 this was resolved rather quickly:
As he was suggesting, the major overhaul of the design patterns in Lollipop requires some sort of AppCompat. Based on that and with a little bit of luck the following additions to the ../values-v19/styles.xml
file made the text appear white in KitKat again:
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/text_primary</item>
</style>
Notice how I added a AppCompat parent to my custom style. I gotta be honest, I'm not exactly sure why it affects the color of the TextViews, if anyone knows feel free to edit or comment. Hope this helps a couple guys in the future.