步骤:
透明度变化
状态图:
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/3a2b6ea391c1fd762b823994e3056a6f.gif)
代码:
AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
alphaAnimation.setDuration(3000);
imageView1.startAnimation(alphaAnimation);
平移:
状态图:
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/20d7622b6fa95f5571a9e70577d0bd87.gif)
代码:
TranslateAnimation animation = new TranslateAnimation(0,imageView1.getMeasuredWidth(), 0, 0);
animation.setDuration(3000);
imageView2.startAnimation(animation);
旋转:
状态图:
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2b0c6103b771f64b1f0f5ecb451bede1.gif)
代码:
RotateAnimation rotateAnimation = new RotateAnimation(0,360);
第一个参数是旋转中心,第二个是旋转角度,旋转中心(0~100%)
rotateAnimation.setDuration(3000);
imageView3.startAnimation(rotateAnimation);
拉伸:
状态图:
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/0f5dabb77adb135880b8a4bc181e2071.gif)
代码:
ScaleAnimation scaleAnimation=new ScaleAnimation(1,0.5f,1,0.5f);
scaleAnimation.setDuration(3000);
imageView4.startAnimation(scaleAnimation);
源码:
layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button_start_animation"
android:text="开始动画"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/animation_imageview5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/b"/>
<ImageView
android:id="@+id/animation_imageview1"
android:layout_width="wrap_content