https://kotlinlang.org logo
#compose
Title
# compose
m

Mark Haehnel

12/10/2019, 1:08 PM
Has anybody else seen problems with missing and broken colors when you use Theme Colors like secondary or error on devices with API level 28 or lower? Here is an example:
Copy code
MaterialTheme() {
  Card(color = +themeColor { secondary }) {
    Text("Test")
  }
}
On API 29 it looks like it should (First attached image 'API_29.png') On API 28 the colors don't get applied and thus the foregound text color is broken too. (Second image 'API_28.png') A little note to the images: Look at the top "tab" bar. The white cards with black text are OK, the ones where the green background is missing are broken.
l

Louis Pullen-Freilich [G]

12/10/2019, 2:32 PM
Can you share your
MaterialColors
definition here?
Are there any other changes when running on 28 vs 29? I'd be suspicious if this is to do with colors, it's more likely that we just aren't drawing the background properly. It's possible that something also changed between the artifacts you are using, and the latest released artifacts (dev03) - would be helpful if you can try with the latest ones too.
(A sanity check would be hard-coding the color of the card to green, instead of using themeColor)
m

Mark Haehnel

12/10/2019, 7:45 PM
Hardcoding the color also doesn't work. There are no other changes to the app when running on 28 instead of 29. That's the MaterialColos definition
Copy code
val lightThemeColors = MaterialColors(
    primary = Color.White,
    primaryVariant = Color.White,
    onPrimary = Color.Black,
    secondary = Color(30, 151, 97),
    onSecondary = Color.White,
    background = Color.White,
    onBackground = Color.Black,
    surface = Color.White,
    onSurface = Color.Black,
    error = Color(200, 0, 0),
    onError = Color.White
)
I will also try dev03 artifacts and will report back after testing.
l

Louis Pullen-Freilich [G]

12/10/2019, 8:09 PM
Yeah, if hardcoding doesn't there's probably some issue with drawing / clipping. If dev03 doesn't work please file a bug 🙂
m

Mark Haehnel

12/10/2019, 8:39 PM
Seems like i need to file a bug. dev03 looks better, but background colors still dont work.
Can you reproduce this?
Just a card a color containing a text.
l

Louis Pullen-Freilich [G]

12/10/2019, 9:30 PM
Can't reproduce (at least with a simple example), if you could file a bug with more code that would be helpful - please include details like what devices you tried on, etc
m

Mark Haehnel

12/11/2019, 5:51 AM
I will.
@Louis Pullen-Freilich [G] I just found out it isn't a bug... I had a style.xml with some colors defined that broke everything on devices with API level 28 and lower.
style.xml like:
Copy code
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="colorPrimary">#FFFFFF</item>
        <item name="colorPrimaryDark">#FFFFFF</item>
        <item name="colorAccent">#1E9761</item>
    </style>

</resources>
l

Louis Pullen-Freilich [G]

12/11/2019, 2:14 PM
Oh, are those components on the screen not using compose then?
m

Mark Haehnel

12/11/2019, 2:15 PM
Not that i know. Just used the compose activity template from android studio added some compose components with colors to the app and then added some styles with styles.xml.
Removing the styles brings back the colors on lower AOU devices
2 Views