You could add an Animation Listener to both animations.
At onAnimationEnd()
of the fade-out animation, set the visibility of the ImageView
to GONE
. Then, start the fade-in animation and on onAnimationStart()
for that one set the visibility of the ImageView
to VISIBLE
.
You don't need to set the position of the image at all, just let the animations do their thing.
EDIT:
Add a translate component to your animations in addition to the fade:
fadein.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="2000" />
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:duration="700" />
</set>
fadeout.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="2000"/>
<translate android:fromXDelta="0%" android:toXDelta="100%"
android:duration="700"/>
</set>