I want the snackbar
to be under the button or at least overlap it
I'm trying to call snackbarHostState.showSnackbar(snackbarText)
when the FloatingActionButton
is clicked, but the call gets this:
In AndroidManifest i have this code:
<activity android:name=".YourActivity"
android:windowSoftInputMode="adjustResize"/>
What might have affected the location of the FloatingActionButton
in Scaffold
:
Scaffold(
snackbarHost = { SnackbarHost(hostState = snackbarHostState) }
floatingActionButtonPosition = FabPosition.End,
floatingActionButton = {
FloatingActionButton(
onClick = { snackbarHostState.showSnackbar(snackbarText) },
modifier = Modifier.visible(fabState?.isVisible ?: false),
) { Icon(Icons.Default.SaveAlt) }
},
// ...
) {}
It is specified in the material3 guidelines that the Snackbar
should display above the FloatingActionButton
.
You should not infringe the guidelines. If you want to, you will need to write your own Scaffold
, as the placement of the Snackbar
is fairly deeply nested in the Composable libraries.