如何解决如何在颤动键盘和焦点TextField之间增加空间?
我在滚动时遇到这个问题,当我聚焦文本字段时,红色容器覆盖了我要写的文本字段。 如何控制滚动,以使文本字段显示在红色容器上方?
我想在keabord上方显示红色的Container,当用户在Textfield中书写时,我要激活nect按钮。
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
FocusNode _focusNode = new FocusNode();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Focus Example"),),body: Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: <Widget>[
Expanded(
flex: 9,// 90% of space => (6/(6 + 4))
child: LayoutBuilder(
builder: (context,constraint) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints:
BoxConstraints(minHeight: constraint.maxHeight),child: IntrinsicHeight(
child: Column(
children: <Widget>[
new Container(
height: 800.0,color: Colors.blue.shade200),new TextFormField(
focusNode: _focusNode,decoration: new Inputdecoration(
hintText: 'Focus me!',new Container(
height: 800.0,],);
},)),Expanded(
flex: 1,// 10% of space
child: Container(
color: Colors.purple,alignment: Alignment.center,Align(
alignment: Alignment.bottomCenter,child: Container(
padding: EdgeInsets.only(left: 10.0,right: 10.0),height: 60,color: Colors.red,child: Row(
crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [
GestureDetector(
child: Text("Back",style:
TextStyle(color: Colors.white,fontSize: 18.0)),onTap: () {}),Container(
width: 40,height: 40,child: FlatButton(
textColor: Colors.white,disabledColor: Colors.grey,disabledTextColor: Colors.white70,padding: EdgeInsets.only(top: 0.0,bottom: 0.0),splashColor: Colors.white,onpressed: () {},child: Icon(
Icons.navigate_next,size: 35,)
],)
],));
}
}
解决方法
我可以给你个主意。尝试这样的事情,
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [
Container(
height: MediaQuery.of(context).size.height * 0.9 - 60,child: Row( ..... ),// Include SingleChildScrollView too
),Container(
padding: EdgeInsets.only(left: 10.0,right: 10.0),height: 60,child: Row( ... )
)
]
希望能解决您的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。