user6597752
user6597752

Reputation: 190

Android button drawing circle effect

Hey guys I just wanna ask question about the default button in android studio when you click it it has effect that it draw circle and fills the button but i wanna know how i can do that in custom button ? thanks for reading

Upvotes: 0

Views: 430

Answers (1)

Zahid Rasheed
Zahid Rasheed

Reputation: 1554

Create a new file "res/drawable/ripple_effect.xml" then add this as background for the button through XML or dynamically.

i.e. android:background="@drawable/ripple_effect"

<?xml version="1.0" encoding="utf-8"?>
<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>

Upvotes: 2

Related Questions