views:

29

answers:

2

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>
A: 

What is the relation between the animation and the layout of views because of which, after the animation, the location of views is not same as before the animation?

dfgmorgan
A: 

A translate animation does not actually change the position of the view. It changes where it is drawn, not its position within the layout.

dfgmorgan