The touch feedback in Android is a must whenever the user clicks on the item or button ripple effect when clicking on the same, gives confidence to the user that the button has been clicked so that they can wait for the next interaction of the app.
As you've noticed, ripples are used subtle indications of touch feedback, hence why they do not use colorPrimary or colorAccent by default. This is consistent with the changes made in Android 4.4 (Kitkat) which made the default selector colors neutral by default.
Ref : http://developer.android.com/training/material/animations.html,
http://wiki.workassis.com/category/android/android-xml/
<TextView
.
.
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
/>
<ImageView
.
.
.
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
/>
If you want the ripple to be bounded to the size of the TextView/ImageView use:
<TextView
android:background="?attr/selectableItemBackground"
android:clickable="true"/>
(I think it looks better)
Please refer below answer for ripple effect.
ripple on Textview or view :
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
ripple on Button or Imageview :
android:foreground="?android:attr/selectableItemBackgroundBorderless"
Add
android:clickable="true"
android:focusable="true"
For Ripple Effect
android:background="?attr/selectableItemBackgroundBorderless"
For Selectable Effect
android:background="?android:attr/selectableItemBackground"
For Button effect
android:adjustViewBounds="true" style="?android:attr/borderlessButtonStyle"
<TextView
android:id="@+id/txt_banner"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/title"
android:background="@drawable/ripple_effect"
android:gravity="center|left"
android:paddingLeft="15dp"
android:text="@string/banner"
android:textSize="15sp" />
Add this into drawable
<?xml version="1.0" encoding="utf-8"?>
<!--this ripple animation only working for >= android version 21 -->
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/click_efect" />
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