animation - Animating LinearLayout background to blink in Android -
the question simple can't manage find solution it. have linearlayout in activity. depending on user need make background of layout blink 3 times. means change background color transparent red , backwards 3 times. let me give example:
- the user receives question , 2 buttons answers
- the user presses wrong answer. layout containing button change it's background (transparent - red, transparent - red, transparent - red - transparen) 3 times.
how can make in android ? thank you.
you use handler postdelayed method. this:
handler h = new handler(); int count = 0; runnable r=new runnable() { public void run() { if(count < 6){ if(count % 2 == 0){ count++; layout.setbackground(red); h.postdelayed(r,500); }else{ count++; layout.setbackground(transparent); h.postdelayed(r,500); } } } }; h.post(r);
Comments
Post a Comment