Animations affect only the drawing of widgets, which means after the animation is done, my FrameLayout screenMain is still at its previous location, y need set the FrameLayout in the next location.
screenMain.setOnClickListener(new View.OnClickListener() {
int i = 0;
@Override
public void onClick(View view) {
if (i % 2 == 0) {
screenMain.startAnimation(translate);
sh.startAnimation(translate);
sg.startAnimation(translate);
i++;
} else {
screenMain.startAnimation(translateb);
sh.startAnimation(translateb);
sg.startAnimation(translateb);
i++;
}
}
});
Code animation
<?xml version="1.0" encoding="utf-8"?>
<set>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0.0"
android:toXDelta="0.0"
android:fromYDelta="0.0"
android:toYDelta="180.0"
android:duration="200"
android:fillAfter="true"
android:fillEnabled="true"
/>
</set>
Code animationb
<?xml version="1.0" encoding="utf-8"?>
<set>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0.0"
android:toXDelta="0.0"
android:fromYDelta="180.0"
android:toYDelta="0.0"
android:duration="200"
android:fillAfter="true"
android:fillEnabled="true" />
</set>