Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ripple effect has a small delay that makes it invisible

I am using android:background="?attr/selectableItemBackground" on a LinearLayout (which acts as a button) to get the ripple effect. When this button is clicked, the current activity slides left during a transition. The problem is that the ripple effect takes some time to be triggered and at the time it becomes visibile, the activity transition has already started, which makes the use of the touch feedback completely useless. I don't want to add a delay to the activity transition, that would be stupid IMO.

XML file looks like this:

<android.support.v7.widget.CardView>

    <LinearLayout
        android:clickable="true"
        android:background="?attr/selectableItemBackground"/>
</android.support.v7.widget.CardView>

How can I make the ripple effect useful and visible ?

like image 247
David Seroussi Avatar asked Nov 01 '17 13:11

David Seroussi


People also ask

What is the ripple effect theory?

A ripple effect can be defined as a gradually spreading influence or series of consequences caused by a single action or event. This ripple effect action begins with stable, well structured opportunities provided by parent leadership initiatives (PLI).

What is an example of ripple effect?

The act of tossing a small stone into the water will result in a change that can be felt much farther away than the initial entry point—proof that small actions can lead to much bigger changes, even if you can't see how far they can reach.

Why is the ripple effect a negative consequence?

A ripple effect describes how the impact of crime can spread beyond the immediate victim throughout their family, friends and community. In other words, it ripples out much wider than the initial victims. Consider the offence of domestic abuse and the number of people this could affect.

What is the ripple effect in business?

The ripple effect is the notion that a single action has an effect over several different entities.


1 Answers

Try to use own drawable for background:

<android.support.v7.widget.CardView>

    <LinearLayout
        android:clickable="true"
        android:background="@drawable/ripple"/>
</android.support.v7.widget.CardView>

And ripple.xml:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="#80585554">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="#your color"/>
        </shape>
    </item>
</ripple>
like image 118
Alexey Zatsepin Avatar answered Sep 21 '22 13:09

Alexey Zatsepin