【问题标题】:How can I get the tap sound when a user touch a gridlayout?当用户触摸网格布局时如何获得点击声音?
【发布时间】:2017-09-23 03:41:33
【问题描述】:

当用户触摸网格布局时如何获得点击声音?

<GridLayout row="3" colSpan="2" columns="15*,75*,10*" height="12%" rows="*,*" class="card-large box" (tap)="onTap()">
    <Label text="&#xf17b;" class="fa centered icon-category" col="0" rowspan="2"></Label>
    <Label text="MyText" class="category-name" verticalAlignment="bottom" col="1" row="0"></Label>
    <Label text="numbers" verticalAlignment="top" col="1" row="1"></Label>
    <Label text="&#xf054;" class="fa centered icon-arrow" col="2" rowspan="2"></Label>
</GridLayout>

更新:我可以通过访问 android 原生 api 来获得声音,这里是代码:

让 decorView:any = app.android.startActivity.getWindow().getDecorView() decorView.playSoundEffect(android.view.SoundEffectConstants.CLICK)

但我想知道为什么点击 android 布局不会触发音效,..

【问题讨论】:

    标签: nativescript nativescript-angular


    【解决方案1】:

    上面的代码应该可以按预期工作。这是a demonstration application,当用户点击布局时会触发音效(the layouttap event,魔法正在发生)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多