My Xml code:
<Button
android:id="@+id/link_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/google_btn" />
I am applying Default ripple effect
<Button
android:id="@+id/link_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" />
but I need button background "@drawable/google_btn"
with"?android:attr/selectableItemBackground"
. it's means i need ripple effect with custom background.
What is Ripple effect in Android? Ripple effect provides an instantaneous visual confirmation at the point of contact when users interact with UI elements. These UI elements could be any of the View elements. Like – Layouts, Buttons, TextViews, ListViews, etc.
Ripple touch effect was introduced with material design in Android 5.0 (API level 21). Touch feedback in material design provides an instantaneous visual confirmation at the point of contact when users interact fwith UI elements.
In your drawable-v21
folder you can write code for ripple effect by your own. Make a drawable xml file and set starting tag by ripple
. Like this :
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/colorAccentDark">
<item>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@color/button_accent_dark"
android:state_checked="false"/>
<item
android:drawable="@color/button_accent"
android:state_checked="true" />
<item
android:drawable="@color/button_accent_dark" />
</selector>
</item>
</ripple>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With