Skip to content
Related Articles

Related Articles

How to Create Shine Effect in Android?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 23 Feb, 2021

Shine Effect is used to give an ImageView, Button, or a View a better animation look. It is very easy to implement. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Kotlin language.


Step by Step Implementation

Step 1: Create a new project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language

Step 2: Working with the activity_main.xml file

Go to the activity_main.xml file and refer to the following code. Below is the code for the activity_main.xml file.


<?xml version="1.0" encoding="utf-8"?>
                android:src="@drawable/ic_baseline_add_24" />
                android:textSize="20sp" />
        <!--This is the view which we will be animating
            in order to show shine effect-->
            android:rotation="20" />

Step 3: Create bg_circular.xml inside the drawable folder we will use it as the background of the Linear Layout

Refer to the How to Create Drawable Resource XML File in Android Studio.


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

Step 4: Create bg_shine.xml inside the drawable folder we will use this as the background of our animating view


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

Step 5: Create left_right.xml inside the anim folder of res. We will use this animation to show it in our View

Refer to this article How to Create Anim Folder & Animation File in Android Studio.

Folder Structure:


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

Step 6: Working with the MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.


import android.os.Bundle
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
class MainActivity : AppCompatActivity() {
    // Initialize the view
    lateinit var shine: View
    override fun onCreate(savedInstanceState: Bundle?) {
        // attach it with the id of view
        // that we will animate
        shine = findViewById(
    private fun shineAnimation() {
        // attach the animation layout Using AnimationUtils.loadAnimation
        val anim = AnimationUtils.loadAnimation(this, R.anim.left_right)
        // override three function There will error 
        // line below the object
        // click on it and override three functions
        anim.setAnimationListener(object : Animation.AnimationListener {
            // This function starts the 
            // animation again after it ends
            override fun onAnimationEnd(p0: Animation?) {
            override fun onAnimationStart(p0: Animation?) {}
            override fun onAnimationRepeat(p0: Animation?) {}


Github repo here.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!