I have an app widget with a white background. Some of the text that displays uses ?android:textColorPrimary
, some uses ?android:textColorSecondary
, and some use colours I've defined.
For some reason though, when I run my app on pre Nougat (24 or lower), the colours are white such that the text is invisible on the white background, but anything 24 and higher shows as black or grey. The colours I've defined are always ok.
What's also interesting is that the code in the app widget is almost identical to the actual app (both displaying a list of items) and the app version (even on these older API's) uses dark colours but the widget for some reason selects white colours for the text.
If I trace through the XML code in the styles I get to this:
<!-- The most prominent text color. -->
<attr name="textColorPrimary" format="reference|color" />
What does this mean? How does it know what the most prominent text colour is? Why is it different in the widget vs the app, and why only on older API versions?
Is there anything I can do to fix this so that it's consistent? I'm using the same theme. Why would this happen?
Note: as far as just setting a specific colour, this is not what I'm asking. Sure I could just set the text to black or something but I want to use these styles so that in the future the colour can change as necessary, especially since I'm using the day/night theme. Maybe it's related to that? Ok I tried a normal theme but the problem persists (text is invisible on the widget - only the widget - on older than API 24).
Please let me know if anything is unclear and I'll update the question. Thanks.