Search code examples
androidkotlinlayoutandroid-jetpack-composeandroid-jetpack

The container color that I am passing is not wrapping the title of MediumTopAppBar


Here's what it looks like:

screenshot

Scaffold(

        topBar = {
            MediumTopAppBar(
                colors = TopAppBarDefaults.mediumTopAppBarColors(
                    containerColor = Color.Yellow
                ),
                // modifier = Modifier.fillMaxHeight(),
                title = { Text(text = "Expense")}

            )
        },

        content = { innerPadding ->

            Column(modifier = Modifier.padding(innerPadding)) {
                Text(text = "Expenses")
            }

        }

    )

Even the fillMaxHeight wasnt able to alter the height of the container color that is shown in the image.


Solution

  • There was a bug described on the Google Issue Tracker. It should be resolved in recent versions of the material3 dependency. Please update your dependency to the latest stable release:

    implementation "androidx.compose.material3:material3:1.2.1"
    

    Let me know if that resolves the issue.