如何使容器的角变圆?

huangapple go评论107阅读模式
英文:

How to make container corner round?

问题

如何使白色容器的右上角和左上角变为圆角,就像下面的图片一样?

如何使容器的角变圆?

return SingleChildScrollView(
  child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
    Container(
      height: MediaQuery.of(context).size.height / 2,
      color: Colors.orange,
    ),
    Container(
      decoration: const BoxDecoration(
        borderRadius: BorderRadius.only(
          topRight: Radius.circular(40.0),
          topLeft: Radius.circular(40.0),
        ),
        color: Colors.white,
      ),
    ),
  ]),
);
英文:

How to make the right upper corner and left upper corner of the white container round, just like below image?

如何使容器的角变圆?

  return SingleChildScrollView(
      child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
        Container(
            height: MediaQuery.of(context).size.height / 2,
            color: Colors.orange),
        Container(
          decoration: const BoxDecoration(
              borderRadius: BorderRadius.only(
                  topRight: Radius.circular(40.0),
                  topLeft: Radius.circular(40.0)),
              color: Colors.white),
        )
      ]),
    );

答案1

得分: 2

Stack(
        children: [
          Expanded(
            child: Container(color: Colors.orange),
          ),
          SingleChildScrollView(
            child:
                Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
              Container(
                  height: MediaQuery.of(context).size.height / 2,
                  color: Colors.orange),
              Container(
                height: MediaQuery.of(context).size.height / 2,
                decoration: const BoxDecoration(
                    borderRadius: BorderRadius.only(
                      topRight: Radius.circular(40.0),
                      topLeft: Radius.circular(40.0),
                    ),
                    color: Colors.white),
              )
            ]),
          ),
        ],
      ),

如何使容器的角变圆?

英文:
Stack(
        children: [
          Expanded(
            child: Container(color: Colors.orange),
          ),
          SingleChildScrollView(
            child:
                Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
              Container(
                  height: MediaQuery.of(context).size.height / 2,
                  color: Colors.orange),
              Container(
                height: MediaQuery.of(context).size.height / 2,
                decoration: const BoxDecoration(
                    borderRadius: BorderRadius.only(
                      topRight: Radius.circular(40.0),
                      topLeft: Radius.circular(40.0),
                    ),
                    color: Colors.white),
              )
            ]),
          ),
        ],
      ),

如何使容器的角变圆?

答案2

得分: 0

使用clipBehavior:Container上。默认值是clipBehavior: Clip.none,

Container(
  clipBehavior: Clip.hardEdge,
   decoration: const BoxDecoration(
英文:

Use clipBehavior: on Container. Default it is clipBehavior: Clip.none,

Container(
  clipBehavior: Clip.hardEdge,
   decoration: const BoxDecoration(

huangapple
  • 本文由 发表于 2023年3月10日 00:19:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687328.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定