android animation一张菊花图片达到帧动画那个样子转

关键就一句话

setInterpolator(new Interpolator() {
    @Override
    public float getInterpolation(float input) {
        return (float)(int) (input * petalCount) / petalCount;
    }
});
给RoattionAnimation加这么个Interpolator

petalCount就是需要旋转的菊花的花瓣数量

简单解释一下就是input 是0-1的float型 先乘以花瓣数量,再转为int型就变成了0到petalCount-1的整数再以浮点数的形式除以花瓣数量,最终就是0到1的浮点均匀分布的花瓣数量的等差数列了。RotationAnimation的旋转角度是0-360度,乘以Interpolation返回的数就是0-360均匀分布的角度,所以最终旋转动画变成了跳跃式的旋转动画。比如花瓣数量为8,就直接从0跳到45度,再到90度,看起来就像是换了一帧一样。

github  https://github.com/keaideluren/StaticLoading.git

你可能感兴趣的:(StaticLoading)