英文:
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(
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论