键盘处于活动状态时如何避免背景图像缩小? [英] How can I avoid the background image to shrink when my keyboard is active?
本文介绍了键盘处于活动状态时如何避免背景图像缩小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个带有文本输入的背景图像,但是我不知道在键盘处于活动状态时应该使用哪个小部件来避免背景图像缩小。
I would like to have a background image with text inputs but I don't know which widget I should use to avoid the background image to shrink when my keyboard is active.
在这里您可以找到问题的两个屏幕快照以及我的代码:
Here you can find two screen shots of the problem and my code:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
var backgroundImage = new BoxDecoration(
image: new DecorationImage(
image: new AssetImage('assets/forest.jpg'), fit: BoxFit.cover));
return new MaterialApp(
home: new Scaffold(
body: new Stack(
children: <Widget>[
new Container(
decoration: backgroundImage,
),
new TextField()
],
)));
}
}
推荐答案
您可以使用属性 resizeToAvoidBottomPadding
从 Scaffold
:
Scaffold(
resizeToAvoidBottomPadding: false,
...
这篇关于键盘处于活动状态时如何避免背景图像缩小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文