Android 安卓动画 属性动画 - 组合动画

引入

属性动画的出现,弥补了补间动画的不足之处,补间动画,只是改变了表面上的东西,但是其中属性并未改变,而属性动画相反,改变了表面上的东西,并且也更改了其属性。


类:ObjectAnimator

用于操作属性动画的类


动画 - 相关文章篇

帧动画

帧动画:  https://blog.csdn.net/qq_40881680/article/details/82222684

 

补间动画

补间动画-平移动画:  https://blog.csdn.net/qq_40881680/article/details/82255459

补间动画-缩放动画:  https://blog.csdn.net/qq_40881680/article/details/82260914

补间动画-旋转动画:  https://blog.csdn.net/qq_40881680/article/details/82261557

补间动画-透明/渐变动画:  https://blog.csdn.net/qq_40881680/article/details/82261869

补间动画-组合动画(四个动画一起播放):  https://blog.csdn.net/qq_40881680/article/details/82285987

 

属性动画

属性动画-渐变透明动画:  https://blog.csdn.net/qq_40881680/article/details/82318363

属性动画-旋转动画:  https://blog.csdn.net/qq_40881680/article/details/82354017

属性动画-缩放动画:  https://blog.csdn.net/qq_40881680/article/details/82377850

属性动画-移动动画:  https://blog.csdn.net/qq_40881680/article/details/82378391

属性动画-组合动画:  https://blog.csdn.net/qq_40881680/article/details/82381258


布局文件 篇




    

        

代码逻辑 篇

属性动画用到的是:ObjectAnimator

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    ObjectAnimator objectAnimator1;
    ObjectAnimator objectAnimator2;
    ObjectAnimator objectAnimator3;
    private Button button;
    private ImageView image;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        button = (Button) findViewById(R.id.button);
        image = (ImageView) findViewById(R.id.image);
        button.setOnClickListener(this);
        image.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:
                objectAnimator1 = ObjectAnimator.ofFloat(image,"translationX",0f,60f,0f);
                objectAnimator2 = ObjectAnimator.ofFloat(image,"translationY",0f,60f,0f);
                objectAnimator3 = ObjectAnimator.ofFloat(image,"alpha",1f,0f);
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.play(objectAnimator1).with(objectAnimator2).before(objectAnimator3);
                animatorSet.setDuration(2000);
                animatorSet.start();
                break;
            case R.id.image:
                Toast.makeText(this, "我是属性动画", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}

 AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(objectAnimator1).with(objectAnimator2).before(objectAnimator3);
animatorSet.setDuration(2000);
animatorSet.start();

再左右移动同时进行上下移动,移动完毕后,再进行透明度的变换,可以此类推往后加

参数不多做解释,不懂请看属性动画的相关文章

属性动画

属性动画-渐变透明动画:  https://blog.csdn.net/qq_40881680/article/details/82318363

属性动画-旋转动画:  https://blog.csdn.net/qq_40881680/article/details/82354017

属性动画-缩放动画:  https://blog.csdn.net/qq_40881680/article/details/82377850

属性动画-移动动画:  https://blog.csdn.net/qq_40881680/article/details/82378391

属性动画-组合动画:  https://blog.csdn.net/qq_40881680/article/details/82381258

效果图展示:

你可能感兴趣的:(Android,Android更上一层楼)