【问题标题】:Flutter container to position bottom right颤振容器定位到右下角
【发布时间】:2021-08-06 23:36:11
【问题描述】:

我有一个颤振容器(紫色趋势文本),它现在位于 左上角。我想知道我应该做哪些代码更改来定位容器右下角?

                     Container(
                        height: 25.0,
                        width: MediaQuery.of(context).size.width * 0.25,
                        margin: const EdgeInsets.all(8.0),
                        decoration: BoxDecoration(
                          color: Theme.of(context).primaryColor,
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(12.0),
                            bottomRight: Radius.circular(12.0),
                          ),
                        ),
                        alignment: Alignment.center,
                        child: Shimmer.fromColors(
                          baseColor: Colors.white60,
                          highlightColor: Colors.white,
                          period: Duration(milliseconds: 1000),
                          child: Text(
                            'Trending',
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: GoogleFonts.poppins(
                              color: Colors.white.withOpacity(0.9),
                              fontSize: 13.0,
                              fontWeight: FontWeight.w500,
                            ),
                          ),
                        ),
                      )

当前视图

【问题讨论】:

    标签: flutter flutter-container


    【解决方案1】:

    将您的图像和文本包装在 Stack 中并设置所需的对齐方式。

    Stack(
    alignment: Alignment.topRight,
    children: <Widget>[
     ...
     ],
    )
    

    【讨论】:

      【解决方案2】:

      首先,您需要将边框半径调整为合适的大小(反转它们)。

      第二个是你应该修改这个Container上方的Stack小部件并将其对齐属性设置为Alignment。右上角!

      【讨论】:

      • 谢谢。如果我想保留两者,我该怎么办?
      • 复制粘贴到堆栈的子列表参数(整个容器小部件)
      猜你喜欢
      • 1970-01-01
      • 2020-10-13
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-30
      • 2021-02-11
      • 2021-05-10
      相关资源
      最近更新 更多