Thread
#compose
    m

    Mark Haehnel

    2 years ago
    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:
    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]

    2 years ago
    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

    2 years ago
    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
    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]

    2 years ago
    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

    2 years ago
    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]

    2 years ago
    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

    2 years ago
    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:
    <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]

    2 years ago
    Oh, are those components on the screen not using compose then?
    m

    Mark Haehnel

    2 years ago
    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