Convert Figma logo to code with AI

traex logoRippleEffect

Implementation of Ripple effect from Material Design for Android API 9+

4,924
1,081
4,924
54

Top Related Projects

This is a library with components of Android L to you use in android 2.2

Android L Ripple effect wrapper for Views

A beautiful ripple animation for your app

View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+

A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop

Quick Overview

RippleEffect is an Android library that provides a material design-inspired ripple effect for views. It allows developers to easily add interactive feedback to user touches, enhancing the visual appeal and user experience of Android applications.

Pros

  • Easy integration with existing Android projects
  • Customizable ripple color and duration
  • Supports both circular and rectangular ripple effects
  • Compatible with a wide range of Android versions

Cons

  • Limited documentation and examples
  • Not actively maintained (last update was several years ago)
  • May not be fully optimized for newer Android versions
  • Lacks advanced features like multi-touch ripple effects

Code Examples

Adding a ripple effect to a view:

View view = findViewById(R.id.myView);
RippleView rippleView = new RippleView(this);
rippleView.addRippleToView(view);

Customizing ripple color and duration:

RippleView rippleView = new RippleView(this);
rippleView.setRippleColor(Color.RED);
rippleView.setRippleDuration(1000);
rippleView.addRippleToView(view);

Using RippleView in XML layout:

<com.andexert.library.RippleView
    android:id="@+id/rippleView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ripple:rv_color="#FFFFFF"
    ripple:rv_centered="true">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button with Ripple Effect" />

</com.andexert.library.RippleView>

Getting Started

  1. Add the JitPack repository to your project's build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.traex:RippleEffect:1.3'
}
  1. Sync your project with Gradle files.

  2. Use RippleView in your layouts or create it programmatically as shown in the code examples above.

Competitor Comparisons

This is a library with components of Android L to you use in android 2.2

Pros of MaterialDesignLibrary

  • Offers a wider range of Material Design components and features
  • Provides more customization options for UI elements
  • Includes additional animations and transitions beyond ripple effects

Cons of MaterialDesignLibrary

  • Larger library size, potentially increasing app size and complexity
  • May have a steeper learning curve due to more extensive features
  • Less focused on specific ripple effects compared to RippleEffect

Code Comparison

RippleEffect:

RippleView rippleView = (RippleView) findViewById(R.id.ripple);
rippleView.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
    @Override
    public void onComplete(RippleView rippleView) {
        // Action after ripple effect completes
    }
});

MaterialDesignLibrary:

ButtonFlat buttonFlat = new ButtonFlat(this);
buttonFlat.setText("Button");
buttonFlat.setBackgroundColor(Color.parseColor("#1E88E5"));
buttonFlat.setRippleColor(Color.parseColor("#BBDEFB"));
layout.addView(buttonFlat);

The code comparison shows that RippleEffect focuses specifically on ripple animations, while MaterialDesignLibrary provides a broader set of Material Design components with built-in ripple effects and other customization options.

Android L Ripple effect wrapper for Views

Pros of material-ripple

  • More customizable with options for ripple color, duration, and fade-out time
  • Supports both circular and rectangular ripple effects
  • Actively maintained with recent updates and bug fixes

Cons of material-ripple

  • Slightly more complex implementation compared to RippleEffect
  • May have a higher performance impact due to additional customization options

Code Comparison

RippleEffect:

RippleView rippleView = (RippleView) findViewById(R.id.ripple);
rippleView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // Handle click event
    }
});

material-ripple:

MaterialRippleLayout.on(view)
    .rippleColor(Color.BLACK)
    .rippleDuration(350)
    .rippleAlpha(0.2f)
    .create();

Summary

Both RippleEffect and material-ripple provide ripple animations for Android views. material-ripple offers more customization options and active maintenance, while RippleEffect has a simpler implementation. The choice between the two depends on the specific requirements of your project, such as the need for customization, performance considerations, and desired ease of use.

A beautiful ripple animation for your app

Pros of android-ripple-background

  • Offers more customization options for ripple effects
  • Supports multiple ripples simultaneously
  • Provides smoother animations and transitions

Cons of android-ripple-background

  • Slightly more complex implementation
  • May have a higher performance impact on resource-constrained devices
  • Less frequently updated compared to RippleEffect

Code Comparison

android-ripple-background:

<com.skyfishjy.library.RippleBackground
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:rb_color="#0099CC"
    app:rb_radius="32dp"
    app:rb_rippleAmount="4"
    app:rb_duration="3000"
    app:rb_scale="6"/>

RippleEffect:

<com.andexert.library.RippleView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    rv_centered="true">
    <!-- Your content here -->
</com.andexert.library.RippleView>

Both libraries provide easy-to-use XML attributes for customization, but android-ripple-background offers more fine-grained control over the ripple effect's appearance and behavior. RippleEffect focuses on simplicity and ease of integration, making it a good choice for basic ripple animations. android-ripple-background is better suited for more complex and visually appealing ripple effects, especially when multiple ripples are needed.

View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

Pros of RippleView

  • Supports custom ripple colors and durations
  • Allows setting ripple as background or foreground
  • Provides more customization options for ripple behavior

Cons of RippleView

  • Less actively maintained (last update in 2015)
  • Fewer stars and forks on GitHub, indicating potentially less community support
  • Limited documentation and examples compared to RippleEffect

Code Comparison

RippleView:

RippleView rippleView = (RippleView) findViewById(R.id.ripple);
rippleView.setRippleColor(Color.parseColor("#ff0000"));
rippleView.setRippleDuration(1000);
rippleView.setRippleType(RippleView.RippleType.DOUBLE);

RippleEffect:

MaterialRippleLayout.on(view)
    .rippleColor(Color.parseColor("#ff0000"))
    .rippleDurationDuration(1000)
    .create();

Both libraries offer similar functionality for creating ripple effects on Android views. RippleView provides more built-in customization options, while RippleEffect uses a builder pattern for configuration. RippleEffect has more recent updates and a larger community, potentially making it a more reliable choice for long-term projects. However, RippleView's additional customization options may be beneficial for specific use cases requiring fine-tuned control over the ripple effect.

Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+

Pros of CircularReveal

  • Offers more customizable and complex reveal animations
  • Supports both circular and rectangular reveal shapes
  • Provides smoother animations on older Android versions

Cons of CircularReveal

  • Requires more setup and configuration compared to RippleEffect
  • May have a steeper learning curve for beginners
  • Limited to API 21+ without additional workarounds

Code Comparison

CircularReveal:

ViewAnimationUtils.createCircularReveal(view,
    centerX, centerY, startRadius, endRadius)
    .setDuration(duration)
    .start();

RippleEffect:

RippleView rippleView = (RippleView) findViewById(R.id.ripple_view);
rippleView.setOnRippleCompleteListener(listener);

CircularReveal offers more granular control over the animation parameters, allowing developers to specify the center point, start radius, and end radius. RippleEffect, on the other hand, provides a simpler implementation with pre-defined ripple animations.

Both libraries serve different purposes: CircularReveal is better suited for complex reveal animations, while RippleEffect excels at creating simple, material design-inspired ripple effects with minimal setup.

A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop

Pros of vector-compat

  • Provides backward compatibility for vector drawables on pre-Lollipop devices
  • Supports animated vector drawables
  • Offers a wider range of functionality beyond just ripple effects

Cons of vector-compat

  • May have a larger footprint due to its broader feature set
  • Potentially more complex to implement for simple ripple effects
  • Less focused on the specific ripple effect functionality

Code Comparison

RippleEffect:

RippleView rippleView = (RippleView) findViewById(R.id.ripple);
rippleView.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
    @Override
    public void onComplete(RippleView rippleView) {
        // Action after ripple effect completes
    }
});

vector-compat:

VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
    getResources(), R.drawable.vector_drawable, getTheme());
imageView.setImageDrawable(vectorDrawable);

AnimatedVectorDrawableCompat animatedVectorDrawable = 
    AnimatedVectorDrawableCompat.create(this, R.drawable.animated_vector);
imageView.setImageDrawable(animatedVectorDrawable);
animatedVectorDrawable.start();

Summary

While RippleEffect focuses specifically on creating ripple animations, vector-compat offers a broader set of features for vector drawable compatibility. RippleEffect may be simpler to implement for basic ripple effects, but vector-compat provides more versatility for working with vector graphics across different Android versions.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

RippleEffect

RippleEffect

ExpandableLayout provides an easy way to create a view called header with an expandable view. Both view are external layout to allow a maximum of customization. You can find a sample that how to use an ExpandableLayout to your layout.

RippleEffect GIF

Integration

The lib is available on Maven Central, you can find it with Gradle, please


dependencies {
    compile 'com.github.traex.rippleeffect:library:1.3'
}

Usage

RippleView

Declare a RippleView inside your XML layout file with a content like an ImageView or whatever.

<com.andexert.library.RippleView
  android:id="@+id/more"
  android:layout_width="?android:actionBarSize"
  android:layout_height="?android:actionBarSize"
  android:layout_toLeftOf="@+id/more2"
  android:layout_margin="5dp"
  rv_centered="true">

  <ImageView
    android:layout_width="?android:actionBarSize"
    android:layout_height="?android:actionBarSize"
    android:src="@android:drawable/ic_menu_edit"
    android:layout_centerInParent="true"
    android:padding="10dp"
    android:background="@android:color/holo_blue_dark"/>

</com.andexert.library.RippleView>

If you want to know when the Ripple effect is finished, you can set a listener on your view

    rippleView.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {

        @Override
        public void onComplete(RippleView rippleView) {
            Log.d("Sample", "Ripple completed");
        }

    });

If you want to add an OnClickListener don't forget to add it to the RippleView like this:

    final RippleView rippleView = (RippleView) findViewById(R.id.rippleView);
    rippleView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //TODO: onRippleViewClick
        }
    });

Customization

You can change several attributes in the XML file, you have to remove "rv_" if you are using a version below v1.1.1 :

  • app:rv_alpha [integer def:90 0-255] --> Alpha of the ripple
  • app:rv_framerate [integer def:10] --> Frame rate of the ripple animation
  • app:rv_rippleDuration [integer def:400] --> Duration of the ripple animation
  • app:rv_ripplePadding [dimension def:0] --> Add a padding to the ripple
  • app:rv_color [color def:@android:color/white] --> Color of the ripple
  • app:rv_centered [boolean def:false] --> Center ripple in the child view
  • app:rv_type [enum (simpleRipple, doubleRipple) def:simpleRipple] --> Simple or double ripple
  • app:rv_zoom [boolean def:false] --> Enable zoom animation
  • app:rv_zoomDuration [integer def:150] --> Duration of zoom animation
  • app:rv_zoomScale [float def:1.03] --> Scale of zoom animation

For each attribute you can use getters and setters to change values dynamically.

Troubleshooting

If you want to use the double ripple you have to set a background for the RippleView or for its child.

Acknowledgements

Thanks to Google for its Material Design :)

MIT License

    The MIT License (MIT)

    Copyright (c) 2014 Robin Chutaux

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.