I am trying to make an animation that will slide from it's current position to the center of the screen and then flip. I have each moving component working properly but once I put them all into a set with the startoffset, the animation doesnt start until that offset ends and it performs all the animations at once. Any help on this is much appreciated.
slide_down.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Slide down -->
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="1000"/>
<!-- Set alpha to fully opaque -->
<alpha
android:fromAlpha="0.8"
android:toAlpha="1.0"
android:duration="1000" />
<!-- Flip image once it's in the center -->
<!-- ***** HERE IS THE only offset I set ****** -->
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:pivotX="50%"
android:fromYScale="1.0"
android:toYScale="1.0"
android:startOffset="1000"
android:duration="200" />
</set>
calling code
Animation anim = AnimationUtils.loadAnimation(getActivity(), slideDirection);
anim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
mCallBack.categorySelected(view.getId());
}
});
view.clearAnimation();
view.startAnimation(anim);
Thanks, Dman
Animation offsets always calculate from the start of the animation. If you want your animations to play one by one, then you have to calculate the offsets yourself.
The following will play the translate for 1 second, then alpha for another second followed by scale for 200ms -
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Slide down -->
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="1000"/>
<!-- Set alpha to fully opaque -->
<alpha
android:fromAlpha="0.8"
android:toAlpha="1.0"
android:startOffset="1000"
android:duration="1000" />
<!-- Flip image once it's in the center -->
<!-- ***** HERE IS THE only offset I set ****** -->
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:pivotX="50%"
android:fromYScale="1.0"
android:toYScale="1.0"
android:startOffset="2000"
android:duration="200" />
</set>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With