Android Studio实现补间动画

本文实例为大家分享了Android Studio实现补间动画的具体代码,供大家参考,具体内容如下

补间动画是给出初始位置和结束位置,中间由系统自动补充的动画

1、补间动画的配置文件:scale.xml

2、布局文件:animal_patching.xml

3、main.java

sacle.xml



    

animal_patching



    

main.java

package com.example.imageview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
    /*
    private static final String TAG = "leo";
    private NotificationManager manager;
    private Notification notification;
    private PopupWindow popupWindow;
    //创建一个数组,内部元素为Bean类型;
    private List data = new ArrayList<>();
     */
    private boolean flag = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cartoon_patching);

        ImageView imageView = findViewById(R.id.image);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //透明度***********************************
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.alpad_1);
//                imageView.startAnimation(animation);
                //旋转************************************
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.rotate);
//                imageView.startAnimation(animation);
                //大小缩放**********************************
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale);
//                imageView.startAnimation(animation);
                //平移************************************
                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.translate);
                imageView.startAnimation(animation);
            }
        });


}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

你可能感兴趣的:(Android Studio实现补间动画)