There is a RelativeLayout and ImageView . For them, animations start simultaneously:
For RelativeLayout :
<set xmlns:android="http://schemas.android.com/apk/res/android"> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="2.0" android:pivotX="50%" android:pivotY="0%" android:duration="500"> </scale> For ImageView :
<set xmlns:android="http://schemas.android.com/apk/res/android"> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.0" android:toXScale="2.0" android:fromYScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:duration="500"> </scale> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0%p" android:toXDelta="-44.5%p" android:fromYDelta="0" android:toYDelta="0" android:duration="500"> </translate> After the end of the animation, a strong flicker of their view appears. Tried clearAnimation(); both setFillBefore(true) and setDrawingCacheEnabled(true); but nothing helped. Who knows the solution?
@Override public void onClick(View v) { back = 2; animationLay = AnimationUtils.loadAnimation(this, R.anim.toolbar_up); layoutDelete.startAnimation(animationLay); animationImg = AnimationUtils.loadAnimation(this, R.anim.delete); imgDelete.startAnimation(animationImg); animationImg.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { Log.i(TAG, "onAnimationStart"); } @Override public void onAnimationEnd(Animation animation) { Log.i(TAG, "onAnimationEnd"); ViewGroup.LayoutParams l = imgDelete.getLayoutParams(); int w = imgDelete.getWidth(); int h = imgDelete.getHeight(); l.height = w + w; l.width = h + h; imgDelete.setLayoutParams(l); layoutDelete.setGravity(Gravity.CENTER); } @Override public void onAnimationRepeat(Animation animation) { Log.i(TAG, "onAnimationRepeat"); } }); }