Make a Button Blink Animate in Android Java

Here is java code to animate android button

You can make a button blink or animate in Android java with this simple code, here i chose a toggle button and then set the animation code to make it blink.

You can try different blinking rates by changing the offset value.

ToggleButton btn =findViewById(;// identify your button here

//this is the code to animate, place it under Onclick method so it will blink when button pressed
Animation anim = new AlphaAnimation(0.5f, 1.0f);
            anim.setDuration(50); //You can manage the blinking time with this parameter


Post navigation


This site uses Akismet to reduce spam. Learn how your comment data is processed.