简体   繁体   中英

No tap sound on button click - android

I am not getting the sound which is generally heard when a user taps on any ui element Button in Android.

heres my button xml

<Button
    android:id="@+id/continue_btn"
    android:layout_width="280dp"
    android:layout_height="45dp"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="82dp"
    android:background="@drawable/continue_btn_bg"
    android:shadowColor="#000000"
    android:shadowDx="-1"
    android:shadowDy="-1"
    android:shadowRadius="2"
    android:text="CONTINUE"
    android:textSize="20sp" />

the sound just doesn't come when I press this button. Touch Sounds are enabled in android settings.

使用button.playSoundEffect(SoundEffectConstants.CLICK);

I experienced that the system will play the sound automatically once you have attached any action. For example "onClick" in xml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM