Here is my code to translate imageview in X direction(from left to right).
final Animation animTrans = new TranslateAnimation(0f, 1f, 0f, 0f);
animTrans.setRepeatCount(0);
animTrans.setDuration(200);
animTrans.setFillAfter(true);
circleImage.startAnimation(animTrans);
When it starts to translate the image is displaced in y axis. Here is a picture of what happpens.
But when i use an xml to translate everything works fine. What is the problem with my code ?
Xml:
<translate
android:fromXDelta="0%p"
android:toXDelta="80%p"
android:duration="200"
android:fillAfter="true"
/>
I can't understand why, but
circleImage.animate().
translationXBy(width).
setDuration(200).
start();
solved my problem. I think maybe its a problem with final Animation animTrans = new TranslateAnimation(0f, 1f, 0f, 0f);
. Those xdelta, ydelta values may be the reason.