0

By setting android:colorForeground in the theme, the main text colours are calculated based on this setting, i.e. android:textColorPrimary and android:textColorSecondary.

I have tested this with API 23 and API 27. In API 23 it is not working and the text colours are based on white. In API 27 it is working as expected.

  • Is this a known bug?
  • Is there an easy workaround?
  • How extended is the bug on different versions of the API?

Thank you very much.

Blcknx
  • 1,921
  • 1
  • 12
  • 38
  • Is it a problem to define `android:textColorPrimary` and `android:textColorSecondary` directly, just like the support library up to 27.1.1 and we all do? If you supspect there's a bug, the [issue tracker](https://issuetracker.google.com/issues) is the place to go. – Eugen Pechanec May 23 '18 at 08:19
  • Well, I don't know what "we all do". If I start a new project, I surely want to start it state-of-the-art, so I take API 27 as point of orientation. Having an overall foreground color setting as default, looks like a good concept to me. If your experience tells you that API 27 is not stable enough, to port it back, I gladly follow your advice. – Blcknx May 23 '18 at 08:52
  • Oh I know what you mean, what I'm trying to say is don't let the technical details get in the way of your business goal. There was no `android:primaryContentAlpha` before API 26 and yet there are plenty of great looking apps. The only reason it was introduced is so that you don't have to define your own text colors and instead override a single theme attribute. Again, if you think it's a rendering bug in AS, report it. If you need a working compatible alternative define your own `primaryContentAlpha` attribute (similar to [this](https://stackoverflow.com/a/29656290/2444099)). – Eugen Pechanec May 23 '18 at 09:25
  • I am not experienced enough in this field, to call it a bug. It's rather Android Studio doing something strange by rendering a feature of 26 in 23. – Blcknx May 23 '18 at 10:09

1 Answers1

0

As far as I can tell this is rather an issue of Android Studio. The Layout Editor is showing a color calculation behaviour for API 23, wich seems to be available from API 26 onwards.

The color requires an attribute primaryContentAlpha which is available for API 26.

I still have to find out, how the fallback behaves for lower API and if I can fix this by a support library.

See: Support library for text color behaviour of API 26?

Blcknx
  • 1,921
  • 1
  • 12
  • 38