【问题标题】:Is it possible to align text at start in a flutter button是否可以在颤动按钮开始时对齐文本
【发布时间】:2019-11-16 14:34:33
【问题描述】:

我有一个非常简单的按钮:

RaisedButton(
   onPressed: () => print(title),
   color: Colors.white,
   elevation: 1,
   child: AutoSizeText(
     title,
     maxLines: 1,
   ),
);

但我需要在开始时对齐文本,这可能吗?我知道 InkWell 选项,但我无法同时获得边框和飞溅效果。

【问题讨论】:

  • 根据我的经验,当您的启动画面因为与RaiseButton 重叠而未显示时,请尝试使用堆栈制作包含第二个堆栈中的启动画面效果的透明容器

标签: android ios flutter


【解决方案1】:
RaisedButton(
   onPressed: () => print(title),
   color: Colors.white,
   elevation: 1,
   child: Text('Button',),
),

【讨论】:

  • 对不起,我犯了一个错误,我不是在寻找一种居中的方法,而是一种在开始时对齐文本的方法
【解决方案2】:
RaisedButton(
   onPressed: () => print(title),
   color: Colors.white,
   elevation: 1,
   child: Text('Your Text Here', textAlign: TextAlign.left)
);

【讨论】:

    【解决方案3】:

    这很适合我

    Positioned(
            bottom: 0.0,
            child: Container(
              width: MediaQuery.of(context).size.width,
              height: 40,
              color: Colors.blue,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  ButtonTheme(
                    minWidth: 100,
                    height: 40,
                    child: RaisedButton(
                      color: Colors.purple,
                      padding: EdgeInsets.all(0),
                      child: SizedBox(
                        width: 100,
                        child: Text(
                          'SKIP',
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 18,
                          ),
                          textAlign: TextAlign.left,
                        ),
                      ),
                      onPressed: () {},
                    ),
                  ),
                  ButtonTheme(
                    minWidth: 100,
                    height: 40,
                    child: RaisedButton(
                      color: Colors.purple,
                      padding: EdgeInsets.all(0),
                      child: SizedBox(
                        width: 100,
                        child: Text(
                          'Next',
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 18,
                          ),
                          textAlign: TextAlign.right,
                        ),
                      ),
                      onPressed: () {},
                    ),
                  ),
                ],
              ),
            ),
          ),
    

    【讨论】:

      猜你喜欢
      • 2019-10-09
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-23
      • 2020-04-07
      相关资源
      最近更新 更多