王学岗属性动画上(七)----------AnimatorSet动画集合

来源:互联网 发布:淘宝网电器城 编辑:程序博客网 时间:2024/06/15 22:55

AnimatorSet动画集合

package com.example.seven;import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; @SuppressLint(“NewApi”) public class MainActivity extends Activity {private ImageView iv_zhangxin;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    iv_zhangxin = (ImageView) findViewById(R.id.iv_zhangxin);    MyClick mc = new MyClick();    iv_zhangxin.setOnClickListener(mc);}private class MyClick implements OnClickListener {    @Override    public void onClick(View v) {     ObjectAnimator scaleXAnimator=ObjectAnimator.ofFloat(iv_zhangxin, "scaleX", 1.0f,2.0f);     ObjectAnimator scaleYAnimator=ObjectAnimator.ofFloat(iv_zhangxin, "scaleY", 1.0f,2.0f);     AnimatorSet animatorSet=new AnimatorSet();     animatorSet.setDuration(5000);     //可以放可变参数,集合(集合里面放动画),List<ObjectAnimator>等等     animatorSet.playTogether(scaleXAnimator,scaleYAnimator);     animatorSet.start();    }}}

AnimatorSet是一个动画集合。

0 1
原创粉丝点击