如何使应用程序中的按钮静音? [英] How to mute the sound of buttons in application?

查看:57
本文介绍了如何使应用程序中的按钮静音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以使android中的点击声音静音吗?我需要使用自己的声音效果.

Is there any way to mute click sound in android? I need to use my own sound effects.

注意:我不想使用手势检测器代替默认的按钮小部件,因为它会影响我的很多屏幕.

Note: I don't want to use gesture detector instead of default button widgets, because it affects plenty of my screens.

推荐答案

我在默认的Flutter按钮中没有找到任何属性.

I didn't find any property in default Flutter buttons.

但是我认为,我找到了声音的来源.这是InkWell小部件.我做了以下技巧,对我有帮助:

But I think, I found the source of sound. This's InkWell widget. I did the trick below and it helped me:

class SilentBtn extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.red,
      child: Material(
        child: InkWell(
          onTap: () => print('OnTap'),
          enableFeedback: false,
          child: Container(
            width: 50,
            height: 50,
            child: Center(
              child: Text(
                ':)',
                style: TextStyle(color: Colors.white, fontSize: 16),
              ),
            ),
          ),
        ),
        color: Colors.transparent,
      ),
    );
  }
}

如果您设置"enableFeedback:false",则不会在此处单击声音.如果是真的,那么声音是可以听见的.

If you set the 'enableFeedback: false' you won't here click sound. If it's true then the sound is hearable.

这篇关于如何使应用程序中的按钮静音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆