Search code examples
androidandroid-theme

App Theme's TextColor being ignored on Samsumg Galaxy Tab 4


I have an android app where I have set the text and background colours as follows in the theme in styles.xml:

<style name="MyAppTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">#28abe3</item>
    <item name="colorPrimaryDark">#0f92ca</item>
    <item name="colorAccent">#0f92ca</item>
    <item name="android:textColor">#8a000000</item>
    <item name="android:textColorPrimary">#de000000</item>
    <item name="android:colorBackground">#fffafafa</item>
    <item name="android:textColorSecondary">#8a000000</item>
    <item name="android:textColorTertiary">#8a000000</item>
</style>

This works great on every device I can find to test it on. However, I have some users running the app on a Samsung Galaxy Tab 4, who are reporting that some of the text views are showing text in a very light shade of grey, almost indistinguishable from the background, instead of the very dark grey specified through the theme. This doesn't affect every TextView in the app, but an example one is shown below:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Text Here"
    android:id="@+id/problematicTextView"
    android:layout_weight="1"
    android:minHeight="25dp"
    style="@android:style/TextAppearance.DeviceDefault.Medium" />

I've tried everything I can think of short of buying a Galaxy Tab 4 to debug this by trial and error, but to no avail. The only distinguishing feature between TextView that appear with the correct dark grey text as opposed to those which appear in the very light grey color is the line:

style="@android:style/TextAppearance.DeviceDefault.Medium"

The ones which work correctly have:

style="@android:style/TextAppearance.DeviceDefault.Small"

but as I understand it, this is only meant to affect the text size rather than color.

What am I missing to style the TextView text colors correctly in a way that works on all devices (targeting API level 16+)?


Solution

  • If you want a consistent theme across all devices, you should avoid using any DeviceDefault styles as those are the ones customized by individual manufacturers.

    I'd instead suggest using one of the AppCompat TextAppearance styles such as Theme.AppCompat.Medium.