4

Ripple animation on the difficulty of the picture button

 3 years ago
source link: https://www.codesd.com/item/ripple-animation-on-the-difficulty-of-the-picture-button.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Ripple animation on the difficulty of the picture button

advertisements

I am attempting to have a ripple effect play when a button is pressed, I have followed many guides on stack overflow and around the web but have not had any success. Can someone point me in the right direction? My XML looks to be correct but nothing happens when I click the button.

Thank you!

Ripple_animation.xml

<?xml version="1.0" encoding="utf-8"?>

<!-- thanks to http://www.viralandroid.com/2015/09/how-to-add-ripple-effect-to-android-button.html !-->

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

</ripple>

applying ripple effect to button

 <ImageButton
        android:id="@+id/one_button"
        android:background="@drawable/ripple_animation"
        android:padding="0dp"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:layout_width="85dp"
        android:layout_height="85dp"
        app:srcCompat="@drawable/one_button_500_500"
        android:layout_below="@+id/four_button"
        android:layout_alignParentStart="true" />


You set the ripple as the background attribute.
That means it is drawn behind the image src.

Instead, set it as the foreground of this view or it's parent:

android:foreground="@drawable/ripple_animation"




About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK