[英]flutter)How can I make the button position automatically adjust according to the screen size?
I'm making a learning app with flutter.我正在制作一个带有颤振的学习应用程序。
In our app, you have to put a button over the picture.在我们的应用程序中,您必须在图片上放置一个按钮。
So, using positioned on the picture, I made it like the picture below.所以,使用定位在图片上,我把它做成了下图。
@override
Widget build(BuildContext context){
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
fit: StackFit.expand,
children: <Widget>[
Image(
image: AssetImage("assets/oral_structure.png"),
fit: BoxFit.fitWidth
),
Positioned(
top:385, left:17,
child: FlatButton(
child: Text('ㅂ', style: TextStyle(fontSize: 30,fontWeight: FontWeight.bold)),
shape: CircleBorder(),
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => B()),);
},
)
),//ㅂ
However, the problem with this is that the position of the buttons changes when using a phone with a large screen.但是,这样做的问题是使用大屏幕手机时按钮的位置会发生变化。
What can be done to prevent this?可以做些什么来防止这种情况发生?
The button seems always in the same place.按钮似乎总是在同一个地方。 It should be independent of screen size.它应该与屏幕尺寸无关。
I suspect your problem is rather with the fontSize
of the text.我怀疑您的问题与文本的fontSize
相关。
Try to remove the fontSize:
, it should fix your problem尝试删除fontSize:
,它应该可以解决您的问题
尝试获取屏幕的宽度和高度,然后用收音机计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.