android - How can increase/decrease duration of translate animation dynamically (on-the-fly) -
in app large text in textview scroll automatically translate animation, , designed 2 button decrease , increasing speed, when change duration it's work after last duration not on-the-fly, want whenever clicked, in moment duration changed.in fact want how change duration of animationdrawable on fly/runtime? ,but, "translation animation"
here did randomly blinking light
final imageview imagelight = (imageview)findviewbyid(r.id.imagelight); lastlightalpha = (float) math.random(); alphaanimation blinklightanimation = new alphaanimation(1.0f, lastlightalpha); blinklightanimation.setduration((long) (math.random() * 3000)); blinklightanimation.setanimationlistener(new animation.animationlistener() { @override public void onanimationstart(animation animation) { } @override public void onanimationrepeat(animation animation) { } @override public void onanimationend(animation animation) { float newalpha = (float) math.random(); alphaanimation blinklightanimation = new alphaanimation(lastlightalpha, newalpha); blinklightanimation.setanimationlistener(this); blinklightanimation.setduration((long) (math.random() * 3000)); lastlightalpha = newalpha; imagelight.startanimation(blinklightanimation); } }); imagelight.startanimation(blinklightanimation);
you can reset animation by
gearanimation.cancel(); gearanimation.reset();
i hope can use parts of code solve issue.
Comments
Post a Comment