How to add a RIPPLE ANIMATION in android studio kotlin ||
STEP 1 :
Add the following code for accessing the library in setting.gradle file 👇👇
maven { url "https://jitpack.io" }
STEP 2:
In the build.gradle file paste the following dependency 👇👇
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
and click on Sync Now button. Also use view binding. Paste the following code
buildFeatures {
viewBinding true
}
STEP 3:
To make the app beautiful use Material3.Light.NoActionBar theme from theme.xml and also delete the default items.
__________________________________________________________________________________________________
Code for the ripple animation in the layout 👇👇
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ripple_animation"
app:rb_color="#FFC107"
app:rb_rippleAmount="4"
app:rb_duration="3000"
app:rb_scale="4"
app:rb_radius="32dp"
___________________________________________________________________________________________________
Kotlin Code:
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.app.rippleanimation.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
var binding: ActivityMainBinding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.image.setOnClickListener {
binding.rippleAnimation.startRippleAnimation()
}
binding.layout.setOnClickListener {
binding.rippleAnimation.stopRippleAnimation()
}
}
}