I am using Android Studio with Jetpack Compose and Material 3. I want to create bot a topappbar and below it multiple tabs. In Material 3, Scaffold is defined as :
@Composable
fun Scaffold(
modifier: Modifier = Modifier,
topBar: @Composable () -> Unit = {},
bottomBar: @Composable () -> Unit = {},
snackbarHost: @Composable () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {},
floatingActionButtonPosition: FabPosition = FabPosition.End,
containerColor: Color = MaterialTheme.colorScheme.background,
contentColor: Color = contentColorFor(containerColor),
contentWindowInsets: WindowInsets = ScaffoldDefaults.contentWindowInsets,
content: @Composable (PaddingValues) -> Unit
): Unit
When I assign a TopAppBar to topBar parameter, it works. Likewise if I add a TopRow with Tab(s) to topBar parameter, this also works. But how do I add a TopAppBar with Tab(s) below it.
Thanks
2
Answers
Maybe you can try this:
Create new file, and put the function inside the topBar parameter.
Hope it works! 🙂
I typically do it like this:
And if you want to raise its elevation just like the topBar when content scrolling ,maybe you could write an animation and listen the change of scrollState