I have a working example for animating two views with two different animations at the same time. But for some reason this just doesn't work on Android 4.4.2 devices (API level 19).
Animations occur, but setFillAfter is not applied, and at the end of the view are displayed as they were at the starting point.
Here is the code:
AnimationSet animationSet = new AnimationSet(true);
animationSet.setFillAfter(true);
ScaleAnimation scaleAnimation = new ScaleAnimation(
zoomPercent, newZoom, zoomPercent, newZoom,
Animation.RELATIVE_TO_SELF, zoomPointX,
Animation.RELATIVE_TO_SELF, zoomPointY);
TranslateAnimation anim = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, translateX,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, translateY,
Animation.RELATIVE_TO_SELF, 0f);
animationSet.addAnimation(anim);
animationSet.addAnimation(scaleAnimation);
animationSet.setDuration(duration);
AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f,0f);
alphaAnimation.setFillAfter(true);
alphaAnimation.setDuration(duration);
relativeLayout.startAnimation(animationSet);
darkOverlay.startAnimation(alphaAnimation);
The layout I'm animating is as follows
<RelativeLayout
android:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.example.DarkOverlayView
android:id="@+id/dark_overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Any suggestion will help. So far I have tried .setFillEnabled (true) on both sets, but with no effect. I also tried to start the second animation after calling the onAnimationStart callback of the first. It also had no result.
Update:
, Animation.getTansformation(long currentTime, Transformation outTransformation), , - .