In my UI the user needs to enter an ID number, if a number is entered that doesn't exist I have a snackbar that informs the user that no such ID exists. The problem is that it's under the soft keyboard. I'm currently configuring the snackbar in a scaffold. I haven't found a way to move the position of the snackbar from the bottom of the screen within the scaffold attributes. I've gotten it to work by creating a SnackbarHost within the column of my UI. Is this the only way or can I define my snackbar placement using the scaffold?
Scaffold(
scaffoldState = rememberScaffoldState(snackbarHostState = snackbarHostState),
topBar = {
TopAppBar(
title = {
Text(
text = "Keep them honest",
modifier = Modifier
.fillMaxWidth(),
textAlign = TextAlign.Center,
fontSize = 40.sp
)
}
)},
content = { padding->
I've found older references in stackoverflow that address this if you were using activities but nothing with Compose.
I have managed to do this by setting the insets myself https://developer.android.com/jetpack/compose/layouts/insets#compose-apis
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
Box(Modifier.safeDrawingPadding()) {
// the rest of the app
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With