1
Hi, I’d like to make a button(Button
) flash on Android.
1
Hi, I’d like to make a button(Button
) flash on Android.
9
Use a Animation to that effect
private Animation animation;
private Button btn;
public void onCreate(Bundle savedInstanceState) {
animation = new AlphaAnimation(1, 0); // Altera alpha de visível a invisível
animation.setDuration(500); // duração - meio segundo
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE); // Repetir infinitamente
animation.setRepeatMode(Animation.REVERSE); //Inverte a animação no final para que o botão vá desaparecendo
btn = (Button) findViewById(R.id.your_btn);
btn.startAnimation(animation);
}
If you want the animation to be stopped after the button is clicked:
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View view) {
view.clearAnimation(); //Pára a animação
}
});
To start the animation again do: btn.startAnimation(animation);
Adapted from this reply
Browser other questions tagged android xml
You are not signed in. Login or sign up in order to post.
What do you mean by "blink"? It can be background color, text color or even show and display the button. Add a few more details to the question.
– André Ribeiro