Android Studio补间动画 Android Studio实现补间动画
G.O.Y 人气:2想了解Android Studio实现补间动画的相关内容吗,G.O.Y在本文为您仔细讲解Android Studio补间动画的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,Studio,补间动画,下面大家一起来学习吧。
补间动画是给出初始位置和结束位置,中间由系统自动补充的动画
1、补间动画的配置文件:scale.xml
2、布局文件:animal_patching.xml
3、main.java
sacle.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:duration="3000"(运动时间) android:toYScale="0.5"(结束大小) android:toXScale="0.5" android:pivotY="50%"(运动中心位置) android:pivotX="50%" android:fromXScale="1"(初始大小) android:fromYScale="1"/> </set>
animal_patching
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/image" android:background="@drawable/boy" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
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<i> extends AppCompatActivity { /* private static final String TAG = "leo"; private NotificationManager manager; private Notification notification; private PopupWindow popupWindow; //创建一个数组,内部元素为Bean类型; private List<Bean> 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); } }); }
加载全部内容