您当前的位置: 首页 >  动画

命运之手

暂无认证

  • 1浏览

    0关注

    747博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【Android】【动画】自定义Animation

命运之手 发布时间:2019-03-28 14:12:00 ,浏览量:1

//模拟TV关闭时的动画
public class TvCloseAnimation extends Animation {

    private float cx;
    private float cy;

    public TvCloseAnimation() {
    }

    //通过Matrix来控制每个插值点的变换参数
    @Override
    protected void applyTransformation(float interpolatedValue, Transformation transfer) {
        Matrix matrix = transfer.getMatrix();
        //通过矩阵来控制缩放参数
        //四个参数分别指:横向缩放比例,纵向缩放比例,缩放中心横坐标,缩放中心纵坐标
        matrix.postScale(1, 1 - interpolatedValue, cx, cy);
    }

    //这个方法可以拿到控件和容器的初始大小
    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        setDuration(500);
        setFillAfter(true);
        setInterpolator(new AccelerateInterpolator());
        cx = width / 2f;
        cy = height / 2f;
    }
}
关注
打赏
1654938663
查看更多评论
立即登录/注册

微信扫码登录

0.0426s