Flutter中如何修改TextButton水波纹效果或完全移除它?
你可以通过修改TextButton的样式来调整或移除点击时的高亮效果:
1. 完全移除点击效果
将overlayColor设置为透明色,即可去掉点击时的蓝色高亮:
SizedBox( width: 145, height: 146, child: TextButton( style: TextButton.styleFrom( overlayColor: Colors.transparent, ), child: const Text('Mentor'), onPressed: () {}, ), )
2. 将点击效果改为黄色
把overlayColor设置为黄色(可搭配透明度调整视觉柔和度):
SizedBox( width: 145, height: 146, child: TextButton( style: TextButton.styleFrom( overlayColor: Colors.yellow.withOpacity(0.3), ), child: const Text('Mentor'), onPressed: () {}, ), )
如果需要更灵活的样式控制,也可以用ButtonStyle定义:
SizedBox( width: 145, height: 146, child: TextButton( style: ButtonStyle( overlayColor: MaterialStateProperty.all(Colors.yellow.withOpacity(0.3)), ), child: const Text('Mentor'), onPressed: () {}, ), )
内容的提问来源于stack exchange,提问作者Utkarsh More
相关产品推荐
相关产品推荐

