Advertisements

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!

How useful was this post?

Do not forget to rate! this helps us to Improve.

Average rating / 5. Vote count:

Read More Like This..

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Advertisements

Safiya Akhtar

Safiya Akhtar is Android Application Developer in India. She is currently working as a public consultant for career and education too, besides blogging and freelancing. She believes that it is never too late or too early to start what you have always dreamed of.

Your Views And Question are Welcome Here!

Advertisements