Welleneffekt zu meiner Schaltfläche mit Schaltflächenhintergrundfarbe hinzufügen?

Ich habe eine Schaltfläche erstellt und möchte dieser Schaltfläche einen Ripple-Effekt hinzufügen!

Ich habe eine Button-BG-XML-Datei erstellt: (bg_btn.xml)

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#FFFFFF" android:endColor="#00FF00" android:angle="270" />
<corners android:radius="3dp" />
<stroke android:width="5px" android:color="#000000" />
</shape>

Und das ist meine Ripple-Effekt-Datei: (ripple_bg.xml)

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="#f816a463"
    tools:targetApi="lollipop">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="#f816a463" />
        </shape>
    </item>
</ripple>

Und dies ist mein Button, den ich als Ripple-Effekt hinzufügen möchte:

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_centerHorizontal="true"
android:layout_marginTop="173dp"
android:textColor="#fff"
android:background="@drawable/ripple_bg"
android:clickable="true" />

Aber nach dem Hinzufügen eines Ripple-Effekts ist der Hintergrund der Schaltfläche transparent und die Schaltfläche wird nur angezeigt, wenn Sie darauf klicken.

Vor dem Klicken auf

Klicken Sie auf

Aber ich brauche sowohl die Hintergrundfarbe der Schaltfläche als auch den Ripple-Effekt. Ich habe einen Teil dieses Codes in verschiedenen Blogs von Stack Overflow gefunden, aber es funktioniert immer noch nicht!

Antworten auf die Frage(24)

Ihre Antwort auf die Frage