代码之家  ›  专栏  ›  技术社区  ›  Dolphin

如何在颤振中使衬垫与行对齐

  •  0
  • Dolphin  · 技术社区  · 4 年前

    现在我使用row来定位颤振中的一些组件,这是我的代码:

    Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Padding(
                        padding: const EdgeInsets.only(top: 8, bottom: 8.0),
                        child: Text(
                          item.subName,
                          style: TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 8,bottom: 8.0,right: 1),
                        child: ButtonTheme(
                            minWidth: 50,
                            height: 30.0,
                            child:RaisedButton(
                              color: Theme.of(context).primaryColor,
                              shape: new RoundedRectangleBorder(
                                  borderRadius: new BorderRadius.circular(5.0)),
                              onPressed: () async {
                                print("pressed");
                              },
                              child: Text("Subscribe"),
                            )
                        ),
                      )
                    ],
                  )
    

    现在我要按钮 subscribe 右对齐,我该怎么做才能让它工作?我这样试过,但失败了:

    padding: const EdgeInsets.only(top: 8,bottom: 8.0,right: 1),
    

    我试着用屏幕的一个像素来制作按钮,但它似乎不起作用。

    3 回复  |  直到 4 年前
        1
  •  1
  •   Md Azharuddin    4 年前

    如果你想要这样的东西:

    enter image description here

    mainAxisAlignment 财产 Row spaceBetween

        2
  •  1
  •   PRATIK PAWAR    4 年前

    你试图添加的是填充,它只包围小部件,它不会将小部件向右对齐。它将在小部件的右侧添加填充。 在 Row() 部件制造 mainAxisAlignment: MainAxisAlignment.spaceBetween . 这将使订阅按钮向右对齐。

        3
  •  1
  •   S.R Keshav    4 年前

    如果希望行的小部件之间有空间。

     Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
      ),
    

    将控件完全对齐在右侧。

           Row(
        mainAxisAlignment: MainAxisAlignment.end,
      ),
    

     Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      ),