I want to add a TopAppBar
to my Compose app, so I did the following:
@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AlternoTubeTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
stringResource(id = R.string.app_name),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
)
},
content = { innerPadding ->
MyAppTheme(modifier = Modifier.padding(innerPadding))
}
)
}
}
}
}
The issue is, when I run the app, there is no color to my TopAppBar
:
Whereas on the preview images, the app bar does have colors:
What can I try next to get the right colors?