I have a BottomSheetScaffold(), on button push the bottomsheet is coming up, all is working fine, but i want to prevent the user from swiping down the bottomsheet. Instead a button on the bottomsheet is use to close it on click.
I see the option drawerGesturesEnabled, but this not doing anything.
You can set its sheetGesturesEnabled parameter to false
BottomSheetScaffold(
sheetGesturesEnabled = false,
…
…
Related
Am I missing something, but why Scaffold's TopAppBar moves out of the screen when keyboard appears?
I have a simple layout:
setContent {
MyTheme {
Scaffold(topBar = { MyTopAppBar() }) {
ScaffoldContent(it)
}
}
}
Where ScaffoldContent is just a Column with a TextField.
When I press a TextField, keyboard opens and moves everything up . How can I make the bar stick at the top?
Tried:
android:windowSoftInputMode="adjustResize" or "adjustPan"
Instead of Scaffold use a Column and add elements there, but moves anyway
Expected:
TopAppBar to be at the top all the time, like in our Views system
Created a LazyColumn with textFields and it seems to have issue with "android:windowSoftInputMode="adjustResize"parameter.
When clicking a text field that needs to move up so it won't be hidden behind keyboard, causes issues when using AdjustResize parameter. The keyboard will open and then close again. It seems that textfield has lost a focus when ui is doing adjustResize.
Simple code example:
LazyColumn(state = rememberLazyListState()) {
for (i in 1..20) {
item {
TextField(value = "item{$i}", onValueChange = {})
}
}
}
And in AndroidManifest.xml I have
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize"
...
Demo to show that keyboard is closed just after it opens. (This issue only happens when to click on item that needs adjustment to be visible when keyboard is open)
LazyColumn Textfield works correctly without AdjustResize focused item will be moved up and everything is fine. The reason why I would like to use AdjustResize is that in my actual app I have undo/redo buttons at the bottom of the screen and I would like to move them up when keyboard is opened, but it seems I need to use AdjustResize to make it work, but that brakes textFields.
So I was wondering how can I make LazyColumn TextFields to work with AdjustResize? (I'm using latest compose version: 1.3.1)
I have some items in a modal sheet layout and when I press an Item, I navigate to another screen. However, when I press back button in the detail screen, the modal sheet reappears with a flashing behavior. I think this is because of recomposition but is there a way to prevent the recomposition without using a box and hiding-revealing the other screen? Any help is appreciated.
Maybe you need to pop the bottom sheet from the backstack?
When navigating to your detail screen from the bottom sheet, get the instance of the BottomSheetNavigator you used to create the ModalBottomSheetLayout and do:
bottomSheetNavigator.popBackStack(backstackEntry, true)
You get the backstackEntry from the lambda when calling bottomSheet(route)
When I use a textfield on the page I designed with expanded, everything gets shrink when the keyboard is opened. How can i disable this.
If you would like not to scroll the page, set Scaffold's resizeToAvoidBottomInset property to false. It will avoid any effect that pops up from the keyboard. But it comes with a caveat If your TextField is placed within the height of keyboard, whatever user types will not be able to see. Try this if it works for you.
you can use singlechildscrollview or listview widget. They will make it scroll.
and you can use MediaQuery.of(context).viewInsets.bottom for padding or margin. Get keyboard height in Flutter.
I'm newbie in the flutter, and when I create a floating button in the navigation bar to show the record form. But when I try to input something to the textfield, the floating button not stay in the bottom (navigation bar)
floating button in the navigation bar
after input something to the textfields
Anyone can help me how to fix this? Thank you
By default, your Scaffold has been instructed to resize itself whenever a keyboard opens up.
This is controlled by the resizeToAvoidBottomInset property of the Scaffold.
When you set it to false, your Scaffold won't resize itself when a Keyboard is open causing your Scaffold to still take up the entire device height behind the Keyboard.
Use it like this,
Scaffold(
resizeToAvoidBottomInset: false