![](/img/trans.png)
[英]How can I make a Flutter app responsive according to different screen size?
[英]flutter)How can I make the button position automatically adjust according to the screen size?
我正在制作一个带有颤振的学习应用程序。
在我们的应用程序中,您必须在图片上放置一个按钮。
所以,使用定位在图片上,我把它做成了下图。
@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()),);
},
)
),//ㅂ
但是,这样做的问题是使用大屏幕手机时按钮的位置会发生变化。
可以做些什么来防止这种情况发生?
按钮似乎总是在同一个地方。 它应该与屏幕尺寸无关。
我怀疑您的问题与文本的fontSize
相关。
尝试删除fontSize:
,它应该可以解决您的问题
尝试获取屏幕的宽度和高度,然后用收音机计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.