代码之家  ›  专栏  ›  技术社区  ›  Kostya Vyrodov

如何在应用程序中静音按钮?

  •  0
  • Kostya Vyrodov  · 技术社区  · 6 年前

    有没有办法在安卓系统中静音点击声音?我需要用我自己的音效。

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

    1 回复  |  直到 6 年前
        1
  •  4
  •   Kostya Vyrodov    6 年前

    我在默认的颤振按钮中找不到任何属性。

    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,
          ),
        );
      }
    }
    

    如果设置“enableffeedback:false”,则不会在此处单击“声音”。如果是真的,那么声音是可以听到的。