【问题标题】:How to align specific elements to the left inside a Column Widget如何将特定元素与列小部件内的左侧对齐
【发布时间】:2021-12-15 04:02:34
【问题描述】:

在以下代码中,我想将名称“Jonny Bas”和“#coder”对齐到最左边

 body: Column(
        children: [
          Center(
           child:Text(
              'Information',
              style: TextStyle(
                fontSize: 20,
                fontWeight: FontWeight.bold,
                color: Colors.black,
              ),
            ),
          ),
         SizedBox(height: 100),
          Text(
              'Praveen Kumar',
            style: TextStyle(
              fontSize: 30,
              fontWeight: FontWeight.bold,
              color:Colors.black,
            ),
          ),
          Text(
              'Coding star- 4',
            style: TextStyle(
              fontSize: 30,
              fontWeight: FontWeight.bold,
              color: Colors.black,
            ),
          ),
        ],
      ),
      backgroundColor: Colors.grey,
    );
  }

【问题讨论】:

    标签: flutter dart containers alignment padding


    【解决方案1】:

    如果您只想在一个或两个小部件中进行更改,则可以使用“对齐”小部件或“定位”小部件,但如果想让所有小部件与父小部件列具有相同的对齐方式,则可以使用 MainAxisAlignment 和 CrossAxisAlignment left/right/etc的指定属性...

    查看下面的文档链接以获取有关如何使用它们的更多信息,

    https://api.flutter.dev/flutter/widgets/Align-class.html

    https://api.flutter.dev/flutter/widgets/Positioned-class.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-04
      • 1970-01-01
      • 2017-09-01
      • 2020-12-19
      • 1970-01-01
      相关资源
      最近更新 更多