Skip to content

Instantly share code, notes, and snippets.

@Levi-Moreira
Last active February 12, 2024 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Levi-Moreira/5ea6a8b24402d8420d9b4e7dc25ad6fc to your computer and use it in GitHub Desktop.
Save Levi-Moreira/5ea6a8b24402d8420d9b4e7dc25ad6fc to your computer and use it in GitHub Desktop.
Modifier Initial Code to include Offsetting of AppBar
val appBarOffset by remember { mutableIntStateOf(0) }
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Box {
LazyColumn(contentPadding = PaddingValues(top = AppBarHeight)) {
items(Contents) {
ListItem(item = it)
}
}
TopAppBar(
// use the appBarOffset to actually move the top app bar.
modifier = Modifier.offset { IntOffset(0, appBarOffset) },
title = { Text(text = "Jetpack Compose") },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = Purple40,
titleContentColor = Color.White
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment