首页 > 解决方案 > 颤振 | 边框半径不适用于 Android

问题描述

我想找出为什么边框半径不会在 Android 上应用小部件的上半部分。
这是Android上的图像

安卓

但是在网络上,它的工作方式如下图所示。

在此处输入图像描述

有谁知道为什么?

代码

    Center(
      child: Card(
        elevation: 1.5,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0))),
        child: SizedBox(
          width: 250.0,
          height: 150.0,
          child: Column(
            children: <Widget>[
              Container(
                width: double.infinity,
                height: 60.0,
                color: Colors.pink[200].withOpacity(0.95),
                child: Center(
                  child: Text('Felicity Jones'),
                ),
              ),
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 8.0),
                  child: Center(
                    child: Text('9:15'),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    ),

标签: androidcssflutter

解决方案


如果您通过更改opacity颜色的方式仔细观察暂时为:

color: Colors.pink[200].withOpacity(0.2),

您会看到左上角和右上角被截断并且没有被颜色填充:

在此处输入图像描述

为了避免这种情况,请使用Card小部件的clipBehavior: Clip.antiAlias,属性来覆盖具有给定颜色的卡片的所有角落。这是更新的结果:

在此处输入图像描述

希望这能回答你的问题。


推荐阅读