Skip to content
Related Articles

Related Articles

Elastic View in Android

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 18 Feb, 2021

In this article, ElasticView is added in android. The ElasticView is a regular CardView, which can flex from user touches. OnClickListener and other various important methods can also be added to the child view of ElasticView. It makes the user interface more attractive thereby enhancing the user experience.


Step 1: Add the support library in build.gradle file and add the dependency in the dependencies section.  It will allow us to add the ElasticView directly in the XML file.


dependencies {         
       implementation 'com.github.armcha:ElasticView:0.2.0'    

Step 2: Add the following code in the activity_main.xml file. In this file, Elastic View with its child view as ImageView is added to the layout.


<?xml version="1.0" encoding="utf-8"?>

Step 3: Add the following code in the MainActivity.kt file. In this file, OnClickListner is added to ImageView so whenever the user clicks on it, the OnClickListner function gets invoked automatically.


package com.madhav.maheshwari.wavelineview;
import android.os.Bundle
import android.view.View
import android.widget.Toast
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        imageView.setOnClickListener(View.OnClickListener {


Refer to the official documentation for more information.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!