简体   繁体   中英

How to avoid a blink in Translate animation for Android?

I have a image at position 0,0 initially. When the user clicks a button I animate the image and move it to 0,100 using

Animation an = new TranslateAnimation(0, 0, 0, listInstanceDetails.DragItemHeight); an.setFillAfter(true);

Since the setFillAfter is true. The animation stays at 0,100. Now the user clicks the button again and I want it to come back from 0,100 to 0,0. So I use the code

Animation an = new TranslateAnimation(0, 0, 100, 0); an.setFillAfter(true);

This is working fine. But when just before the second animation starts from 100,0 It gives a blink at 0,0 and then starts from 100,0 to 0,0. This looks very ugly.

Is there a way to avoid this blink. Is there anyone who has played around a lot with Translate animation and done a similar operation. Am I doing something wrong. Please let me know your inputs. Thank you for your time and advice.

I had used an.setFillBefore(false); in my code. I removed it and it started working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM