我有一个工作示例,可以同时为两个不同的动画制作动画.但由于某些原因,这在Android 4.4.2(API级别19)设备上不起作用.
动画发生,但不应用setFillAfter,最后,视图将以起始点返回.
这是代码:
// Creating an animation set
AnimationSet animationSet = new AnimationSet(true);
animationSet.setFillAfter(true);
// Creating a Scale Animation
ScaleAnimation scaleAnimation = new ScaleAnimation(
zoomPercent, newZoom, zoomPercent, newZoom, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, zoomPointX, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, zoomPointY); // Pivot point of Y scaling
// Creating a Translate animation
TranslateAnimation anim = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, translateX,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, translateY,
Animation.RELATIVE_TO_SELF, 0f);
//Adding the animations to the set
animationSet.addAnimation(anim); …Run Code Online (Sandbox Code Playgroud)