简体   繁体   English

flutter)如何让按钮位置根据屏幕大小自动调整?

[英]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.

相关问题 如何根据不同的屏幕尺寸使 Flutter 应用响应? - How can I make a Flutter app responsive according to different screen size? 无论屏幕大小如何,如何使容器保持原位 - How Can I Make a Container stay in position no matter the size of the screen in flutter 如何让flutter app根据不同的屏幕尺寸做出响应? - How to make flutter app responsive according to different screen size? 如何根据不同的屏幕尺寸使 flutter web drawer 响应? - how to make flutter web drawer responsive according to different screen size? 在 Flutter 中根据手机屏幕大小移动/调整内容 - Move/adjust content according to a phone's screen size in Flutter 如何根据设备字体大小调整Flutter App的字体大小 - How to adjust Font Size of Flutter App according to Font Size of Device 如何通过在 flutter 应用程序中根据设备屏幕大小调整字体大小来修复文本的 position? - How to fix the position of the text by resizing the font size according to the device screen size in flutter app? flutter 可以在不同的设备上自动调整小部件大小吗? - can flutter adjust widget size automatically in different device? 有 SingleChildScrollView 时,如何在颤动中调整屏幕底部的按钮? - How to adjust the button on the bottom of a screen in flutter, when having SingleChildScrollView? 如何根据屏幕大小颤动设置小部件位置 - how to set a widget place according to screen size flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM