Liquid Button in Android

Android app interfaces often contain the liquid button. This particular design showcases fluid animation that gives the impression of a constantly morphing and shape-shifting button when it is interacted with.

To create a lively and captivating user experience, modern app designs frequently incorporate these buttons. Excitingly, when liquid buttons are tapped or swiped, they respond with smooth and fluid animations, which can be incredibly enjoyable to interact with.

On social media platforms, a prevalent feature is the heart-shaped "like" button. Once pressed, the button emits a fluid animation that gives the illusion of it "growing" or "pulsating" on some apps like Twitter or Instagram. Interacting with this button creates an entertaining visual effect which enhances user engagement.

Importance of Liquid Buttons in Java

From messaging and social media to productivity tools and games, liquid buttons can be discovered in a diverse range of apps. Their value shines through in situations where repetitive or recurring tasks occur and they serve to improve the overall user experience by making interactions feel more intuitive and engaging.

For those seeking out innovative design elements that are sure to delight users, liquid buttons are definitely worth investigating. These visually captivating elements add a playful touch to any Android app design whilst ensuring that user interaction remains engaging. If you're curious about user experience or app design, consider delving into the world of liquid buttons!

Implementing Liquid Button using Java

Implementing liquid buttons is a cool feature that you should try for yourself now that you understand what they are. Let’s look at the steps to do the same.

Adding the Lottie animation library is where you should start when working on your project. Adding the Lottie animation library to your Android project is step one in incorporating Lottie animations. After adding the dependency, it is important to synchronize your project so that the library is downloaded and accessible in your application.

If you wish to adjust your app. Simply insert the dependency outlined below into your application level build.gradle file −

implementation ''
  • Following the first step, you can proceed with creating a liquid animation for your button. This can be done with Adobe After Effects or online animation editors like

Using either the LottieFiles website or the Bodymovin plugin for Adobe After Effects, export your animation as a Lottie file. Pop the file into the "res/raw" directory of your app.

  • Next, in your XML layout file, create a LottieAnimationView element to showcase the fluid animation and ensure to correctly set the app:lottie_rawRes attribute to represent the resource ID of your Lottie file.

   app:lottie_rawRes="@raw/my_liquid_animation" />
  • Load your animation in java code by creating a new LottieAnimationView object and setting its animation source to your Lottie animation file in your activity or fragment code

LottieAnimationView button = findViewById(;
  • To guarantee interactivity for our button, we recommend integrating an OnClickListener. This action will initiate the liquid animation feature upon pressing the button.

button.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
  • You can additionally customize various properties of the LottieAnimationView object to change the appearance and behavior of the liquid button.


  • Create a new class for the main activity, extending AppCompatActivity.

  • Override the onCreate method.

  • Set the content view for the activity with the appropriate layout file.

  • Find the liquid button view using findViewById and assign it to a variable.

  • Set the animation for the liquid button using setAnimation and specify the animation file.

  • Set an OnClickListener for the liquid button and define the desired behavior.

Sample Code Base for Android Liquid Button

Let’s look at a simple code base for creating a liquid button in android.


import android.os.Bundle;
import android.view.View;
import com.airbnb.lottie.LottieAnimationView;

public class MainActivity extends AppCompatActivity {

   private LottieAnimationView liquidButton;

   protected void onCreate(Bundle savedInstanceState) {

      liquidButton = findViewById(;

      liquidButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) {

            // Show confetti animation
            LottieAnimationView confetti = findViewById(;

The code introduces a "liquid button" that provides visual feedback to the user when a payment is successful. The liquid button is represented by a LottieAnimationView element with the ID liquid_button in the layout.

Initially, the liquid button is set to display an animation (payment_success.json) representing a successful payment. When the user clicks the liquid button, the animation is changed to display a tick mark (tick_mark.json). The tick mark animation is then played, indicating a successful payment.

In addition to the liquid button, a confetti animation is included in the layout, represented by another LottieAnimationView element with the ID confetti_animation.


You now know the purpose of a liquid button in android and how you can create one yourself. The sample code provide above is in the Java language and represents a liquid button for successful payment of a user. It uses LottieAnimationView that basically triggers a tick mark followed by a confetti displayed on the screen when the user makes a successful payment.

Updated on: 28-Jul-2023


Kickstart Your Career

Get certified by completing the course

Get Started