Reputation: 43
I am trying to set the background color of TopAppBar using jetpack compose but I am unable to do it. All the posts on the internet use a property called backgroundColor to change the background color but I cannot see any property like that. I also tried using Modifier.background() to change the color but nothing changed. Can someone tell how to change the background color of TopAppBar?
I tried Modifier.background() and backgroundColor property (This property is just not there)
Upvotes: 3
Views: 1041
Reputation: 14857
TopAppBar
have colors
as a parameter.
You can set the color like this,
CenterAlignedTopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.background,
),
// Other parameters
)
Since the question does not have a minimum reproducible example, I have shared an example using CenterAlignedTopAppBar
from Material 3.
Upvotes: 2