属性组合动画

public class MainActivity extends AppCompatActivity {
    private ImageView imageView;
    private int in = 5;
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (in > 0) {
                in--;
                handler.sendEmptyMessageDelayed(0,1000);
            } else {
                Intent intent = new Intent(MainActivity.this, Main2Activity.class);
                startActivity(intent);
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        handler.sendEmptyMessageDelayed(0,1000);
    }

    /**
     * 初始化控件
     */
    private void initView() {
        imageView = (ImageView) findViewById(R.id.imageView);
        //      旋转
        PropertyValuesHolder propertyValuesHolder1 = PropertyValuesHolder.ofFloat("rotation", 0f, 360f);
//      x轴方向平移
//        PropertyValuesHolder propertyValuesHolder2 = PropertyValuesHolder.ofFloat("translationX", 0f, 200f);
//      y轴方向平移              "alpha", 0f, 1f
        PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("translationY", 0f, 200f);
        PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("scaleY", 5f, 1f);
        PropertyValuesHolder propertyValuesHolder5 = PropertyValuesHolder.ofFloat("alpha", 0f, 1f);
        ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, propertyValuesHolder1, propertyValuesHolder3, propertyValuesHolder4, propertyValuesHolder5);
//      设置间隔时间
        objectAnimator.setDuration(5000);
//      开始动画
        objectAnimator.start();
        Toast.makeText(MainActivity.this, "跳转", Toast.LENGTH_SHORT).show();

    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值