英文:
How to prevent the keyboard from pushing content upwards?
问题
有一个包含列的脚手架。列中有两个小部件;一个是图像,另一个是文本。图像包裹在一个扩展小部件中,因此将文本推到屏幕底部。如果以这种设计打开键盘,键盘会将文本向上推,而不是遮挡它。
是否有可能使键盘遮挡小部件而不是将它们向上推,而不需要任何外部包?
英文:
There is a scaffold with a column. Inside the column there are two widgets; one is an image and the other is a text. The image is wrapped around an expanded widget therefore, pushing the text to the bottom of the screen. If you open the keyboard with such a design then, the keyboard will push the text upwards instead of walking over it.
Is it possible to make the keyboard walk over widgets instead of pushing them upwards without any external packages?
答案1
得分: 4
尝试在您的Scaffold小部件下添加resizeToAvoidBottomInset:false
。之后键盘将不会推动列向上。
英文:
Try resizeToAvoidBottomInset:false
under your Scaffold widget. After that keyboard won't push column up.
答案2
得分: 1
你可以使用SingleChildScrollView小部件和NeverScrollableScrollPhysics(),如下例所示,防止键盘打开时屏幕调整大小:
return Scaffold(
body: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: ...
英文:
You can use SingleChildScrollView widget and NeverScrollableScrollPhysics() like below example to prevent screen resizing when keyboard is open
return Scaffold(
body: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: ...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论