I have a train that rotates 45 degrees on a circular track every time a button is pressed, but it flickers when it reaches each 90degrees. The way I approached it was by placing an invisible train at every 90 degrees on the track. When the animation is complete, I use the listener to make the train at the final destination visible because the animated version will disappear, which causes the flicker. When the train reaches destination it disappears, an the animation complete code makes the invisible view visible. Is there a better way to do this so no flicker occurs? I animate as follows:
RotateAnimation animation = new RotateAnimation(index*90f,index2*90.0f,Animation.RELATIVE_TO_PARENT,0.50f,Animation.RELATIVE_TO_PARENT,0.50f);
animation.setDuration(2000);
animation.setAnimationListener(listener);
animation.reset();
View view = findViewById(R.id.train);
view.clearAnimation();
view.startAnimation(animation);
animation.setFillAfter(true);Depending on the android version you’re using though this may not work as expected.