Skip to content

Material Theming: Android Basics with Compose #142

@Mohamedahmed-Abdelgadir

Description

[URL of codelab]
(https://developer.android.com/codelabs/basic-android-kotlin-compose-material-theming?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-3-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-material-theming#3)

In which task and step of the codelab can this issue be found?
Task: Add a color
Step: Color Mapping

Describe the problem
Cards don't use the surfaceVariant color automatically. I had to specify it in the code:

       Card(
        modifier = modifier,
        colors = CardDefaults.cardColors(MaterialTheme.colorScheme.surfaceVariant)
    ) {
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(dimensionResource(id = R.dimen.padding_small))
        ) {
            DogIcon(dog.imageResourceId)
            DogInformation(dog.name, dog.age)
        }
    }

Steps to reproduce?
Just follow the codelab normally, and add the card without explicitly specifying a color for it.

Versions
Android Studio version: Narwhal 2025.1.1 Patch 1
API version of the emulator: API 36.0-ext18

Additional information

Without explicitly specifying surfaceVariant for the cards:

Image

After specifying it:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions