user-interface - 具有可见半径和图像的圆形按钮作为孩子
问题描述
目标:实现具有可见半径和图像的完美尺寸圆形按钮
从上图可以看出,我尝试了很多这里社区提到的解决方案
包含:
- 圆形头像
CircleAvatar(
child: Image.asset('assets/images/gucci.jpg')
)
- ClipRRect
ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.asset(
'assets/images/gucci.jpg',
height: 100.0,
width: 100.0,
)
)
- 以Ink.image作为子小部件的材质小部件
Material(
elevation: 1.0,
shape: CircleBorder(),
clipBehavior: Clip.hardEdge,
color: Colors.transparent,
child: Ink.image(
image: AssetImage('assets/images/gucci.jpg'),
fit: BoxFit.cover,
width: 120.0,
height: 120.0,
child: InkWell(
onTap: () {},
)
)
)
关于如何实现这个设计的任何想法?
解决方案
您有很多选择。其中之一是“FloatingActionButton”。
SizedBox(
width: 60,
height: 60,
child: FittedBox(
fit: BoxFit.contain,
child: FloatingActionButton(
onPressed: () {},
shape: CircleBorder(
side: BorderSide(
color: Colors.black,
width: 1,
),
),
backgroundColor: Colors.white,
child: Padding(
padding: EdgeInsets.all(5),
child: Image.asset('assets/images/gucci.jpg'),
),
),
),
)
我更喜欢它,Container
因为所有按钮的属性,如onPressed
或点击动画都已经实现FloatingActionButton
,你不需要使用GestureDetector
或InkWell
。
您也可以CircleBorder
在任何其他接受 a 的Button
s 或s 中使用。Widget
ShapeBorder
推荐阅读
- http - 有人可以给我 esp32 cam 的代码,以便使用 http post 方法将捕获的图像上传到本地服务器吗?
- sql - SQL 查找具有特定缺失属性的“客户”
- javascript - 指定的值“IN072”不是有效数字。该值必须与以下正则表达式匹配:-?
- reactjs - 如何使用 nginx 将所有 http 请求重定向到 https 以进行反应
- node.js - 节点快速路由中的 HTTPS 请求
- html - 如何仅在选定项目上动态应用 CSS [Angular]
- c - 为什么c中的createfile函数停止for循环
- sql-server - 处理Queue格式的表数据
- aws-codepipeline - 如何从 aws 代码管道执行 selenium UI 测试脚本
- javascript - 有没有一种方法可以让我使用 extjs 将我从网格面板中选择的条目放到字段标签中?