android – 同时缩小和淡入imageView

我正在制作一个包含
ImageView的闪屏.

我想淡入并同时缩小ImageView(同时).
我使用下面的xml来缩小动画:

<scale  xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromXScale="5" 
        android:toXScale="1" 
        android:fromYScale="5" 
        android:toYScale="1" 
        android:pivotX="50%" 
        android:pivotY="50%" 
        android:duration="1000" 
        android:fillAfter="true">
</scale>

以下是Java代码:

Animation zoomout = AnimationUtils.loadAnimation(this, R.anim.zoomout);
imageView.setAnimation(zoomout);

对于淡入淡出的动画,我使用下面的Java代码:

    Animation fadeIn = new AlphaAnimation(1, 0);  
    fadeIn.setInterpolator(new AccelerateInterpolator());
    fadeIn.setStartOffset(500);
    fadeIn.setDuration(1000); 
    imageView.setAnimation(fadeIn);

但是我没有同时做到这一点.
如何在ImageView上同时使用这两个效果?

最佳答案 将以下内容添加到xml缩小:

 <?xml version="1.0" encoding="utf-8"?>
 <set xmlns:android="http://schemas.android.com/apk/res/android"
     android:fillAfter="true"
     android:fillEnabled="true">

    <alpha
        android:duration="1000"
        android:fromAlpha="1.0"
        android:startOffset="1"
        android:toAlpha="0.0"/>

    <scale
        android:duration="1000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale=".5"
        android:toYScale=".5"/>
</set>

并删除淡入淡出动画的java代码

Animation fadeIn = new AlphaAnimation(1, 0);  
fadeIn.setInterpolator(new AccelerateInterpolator());
fadeIn.setStartOffset(500);
fadeIn.setDuration(1000); 
imageView.setAnimation(fadeIn);

这是参考http://thegeekyland.blogspot.com/2015/12/android-animations-explained.html

点赞