I am trying to move an arrow image with translate and rotate animation periodically. I have implemented the animation on Imageview. When the animation stops for the first time the imageview stays at the new posit开发者_如何学运维ion but when another animation starts say after 5 seconds the animation should start from the new position but it always starts from the position which has been specified in xml. Do I need to do anything else in order to make sure that animation always starts from new position of imageview?
I guess you have implements the AnimationListener::onAnimationEnd and the set the new position in the method onAnimationEnd() for the arrow image. So the it stays at he new position. So check your translate animation, make sure it is use the xType, yType as Animation.RELATIVE_TO_SELF. Please refer TranslateAnimation::TranslateAnimation public TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue) {
Hope it will helps.
You need to either start the next animation where the old one finished or reset the LayoutParams of the arrow to place it where it stopped. If you get flickering try setting the LayoutParams before the animation starts and just do the reverse movement (moving from the old position to 0,0 instead of 0,0 to the new position). Hope this helps.
精彩评论