Friday, September 10, 2010

[android-developers] Android Animations do not affect layout

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?

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>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment