I have an ImageView located in a relative layout. I'm moving the ImageView from the top of the screen to the bottom by using a Timer. Below is the code of the timer
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
ObjectAnimator anim= ObjectAnimator.ofFloat(submarine, "translationY", submarine.getTop(), submarine.getTop()+50);
anim.setDuration(1000);
submarine.setTop(submarine.getTop()+50);
submarine.setBottom(submarine.getBottom()+50);
//submarine.startAnimation(sub_down);
anim.start();
}
});
}
}, 0, 3000);
The ImageView is called submarine. The animation works fine but when I change the value of some TexViews in the same RelativeLayout the position of the ImageView is being reset to it's original position. I've also tried using the View animations of Android but the result was the same. Is there any way to avoid the resetting of the submarine ImageView and maintain it's changed position?