Ripple Button(Custom Layout) In Android Studio

Amazing UI Attracts Most Of the Users whether developing a website or Mobile Application. Ripple Effect is one of the very flattering way to take a step towards amazing UI. To Create A ripple effect in android studio you have to create a custom layout file in drawable folder.

Use this Drawabe file toAdd Ripple effect to any layout or attribute in android studio.

Create A New Drawable Resource File. In ButtonRipple.xml write following code:

<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/colorOther2"> <item android:state_pressed="false"> <shape android:shape="rectangle"> <solid android:color="@color/colorPurple4"/> <corners android:radius="50dp"></corners> </shape> </item> <item android:state_pressed="true"> <shape android:shape="rectangle"> <solid android:color="@color/background_image"/> <corners android:radius="50dp"></corners> </shape> </item> </ripple>

Now in your Activity Layout MainActivity.xml write this:

 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Save"
        android:layout_margin="20dp"
        android:background="@drawable/buttonripple"
        android:textColor="#fff"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

Run Your Application and Click On Button to see Ripple Effect. Please Like And Share!

Advertisements

Your Views And Question are Welcome Here!