Android 5.0特新中ViewAnimationUtils的使用

7.0来了,5.0的特性掌握了吗?下来个图
这里写图片描述
这样的动画就是5.0特性里面ViewAnimationUtils提供给我们的;先看方法说明

这里写图片描述
这个方法能做2件事,1是返回一个动画对象,2是讲图片裁剪为一个圆;下面是参数说明:
这里写图片描述
第一个参数:代表的是你要操作的view,第二个是圆的x方向的中点,第三个是圆的y方向的中点,第四个是这个圆开始时候的半径,第五个是结束时候的半径;下面就是代码了:

public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn://这里的代码和本博客没啥关系
                getWindow().setExitTransition(new ChangeTransform());
                Intent intent = new Intent(MainActivity.this, Main2Activity.class);
                startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
                break;
            case R.id.btn1:
                int centerX = mImageView.getWidth() / 2;//获取组件的宽的一半
                int centerY = mImageView.getHeight() / 2;//获取组件的高的一半
                Animator animator = ViewAnimationUtils.createCircularReveal(mImageView, centerX, centerY, mImageView.getWidth(), 0);
                animator.setDuration(3000);
//                animator.setStartDelay(1000);//这里可以设置动画的延迟时间;
                animator.setInterpolator(new LinearOutSlowInInterpolator());//out到in
                animator.start();
                animator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                    }
                });
                break;
            case R.id.btn2:
                Animator animator1 = ViewAnimationUtils.createCircularReveal(
                        mImageView, 0, 0, 0, (float) Math.hypot(mImageView.getWidth(), mImageView.getHeight()));//宽的平方加上高的平方的根号
                animator1.setInterpolator(new LinearInterpolator());//插补器有没有不影响
                animator1.setDuration(2000);
                animator1.start();
                break;

            case R.id.btn3:
                int cenX = mImageView.getWidth() / 2;
                int cenY = mImageView.getHeight() / 2;
                Animator an = ViewAnimationUtils.createCircularReveal(mImageView, cenX, cenY, 0, cenX);
                an.setDuration(3000);
                an.start();
                an.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        mImageView.setVisibility(View.VISIBLE);
                    }
                });
                break;

            case R.id.btn4:
                mImageView.setVisibility(View.VISIBLE);
                break;
        }
    }
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值