I tried to do a simple animation from bottom left corner to right center and then to center of the screen
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidthPx = size.x;
screenHeightPx = size.y;
final TranslateAnimation slideFromRight = new TranslateAnimation(screenWidthPx, screenWidthPx/2, screenHeightPx, screenHeightPx);
slideFromRight.setInterpolator(new AccelerateDecelerateInterpolator());
slideFromRight.setStartOffset(300);
slideFromRight.setDuration(600);
slideFromRight.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
TranslateAnimation titleIconSlideUp = new TranslateAnimation(0, screenWidthPx/2, screenHeightPx, screenHeightPx/2);
titleIconSlideUp.setInterpolator(new AccelerateDecelerateInterpolator());
titleIconSlideUp.setStartOffset(500);
titleIconSlideUp.setFillAfter(true);
titleIconSlideUp.setDuration(1000);
tvAnimView.startAnimation(titleIconSlideUp);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
tvAnimView.startAnimation(slideFromRight);
the second animation inside onAnimationEnd is working fine. But don't know why first animation is not working fine. where my layout is simple
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
tools:context="broadpeak.animationlearning.AnimTestActivity">
<TextView
android:id="@+id/tv_anim_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World"
android:textColor="@color/colorPrimaryDark"
android:textSize="24sp" />
</RelativeLayout>