Android开发之Animations(三)
来源:互联网 发布:旅游景点地图软件 编辑:程序博客网 时间:2024/05/17 23:39
什么是AnimationSet?
1.AnimationSet是Animation的子类;
2.一个AnimationSet包含了一系列的Animation;
3.设置AnimationSet对象的属性,相当于设置的AnimationSet对象包含的所有Animation对象属性
4.使用AnimationSet可以整合多种动画效果
AnimationSet的使用方法
1.在MainActivity.java中创建一个AnimationSet对象,然后再创建多个动画对象
2.将多个动画对象添加到AnimationSet对象中
3.设置AnimationSet对象的属性
4.将ImageView对象与AnimationSet对象进行绑定
MainActivity.java:
package com.mycompany.animations3;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.AnimationUtils;import android.view.animation.RotateAnimation;import android.widget.Button;import android.widget.ImageView;public class MainActivity extends AppCompatActivity { private ImageView imageView; private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView); button = (Button) findViewById(R.id.button); button.setOnClickListener(new ButtonListener()); } class ButtonListener implements View.OnClickListener{ @Override public void onClick(View v) { // 创建AnimationSet对象 AnimationSet animationSet = new AnimationSet(true); // 创建多个动画对象 AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f); RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // 将多个动画对象添加到AnimationSet对象中 animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(rotateAnimation); // 设置AnimationSet对象的属性 animationSet.setDuration(3000); animationSet.setStartOffset(2000); // 将ImageView对象与AnimationSet对象进行绑定 imageView.startAnimation(animationSet); } }}
什么是Interpolator?
Interpolator定义了动画变化的速率,在Animations框架当中定义了以下几种Interpolator:
AccelerateDecelerateInterpolator:在动画开始与结束的地方速率改变比较慢,在中间的时候开始加速
AccelerateInterpolator:在动画开始的地方速率改变比较慢,然后开始加速
CycleInterpolator:动画循环播放特定的次数,速率沿着正弦曲线改变
DecelerateInterpolator:在动画开始的地方速率改变比较慢,然后开始减速
LinearInterpolator:以均匀速率改变
Interpolator的使用方法
Interpolator属性可以在Animation resource file中设置,也可以在代码中进行设置
0 0
- Android开发之Animations(三)
- android开发之Animations的使用(三)
- Android开发之Animations(二)
- Android开发之Animations(四)
- Android开发之Animations(六)
- android开发之Animations的使用(一)
- android开发之Animations的使用(二)
- android开发之Animations的使用(四)
- animations之三interpolator
- android示例之Animations(1)
- android示例之Animations(2)
- android示例之Animations(3)
- android之Animations(动画)
- Android之 Animations动画
- Animations使用(三)
- android Animations 动画效果(三)
- Android Animations(三):卡片翻转动画(Card Flip)
- Android动画(Animations)
- redis中跑lua脚本删除指定key
- 小白日记24:kali渗透测试之提权(四)--利用漏洞提权
- OpenWRT用AP+WDS模式搭建无线中继
- 1.11线程组不可控异常的处理
- Eclipse调试java程序遇见的无伤大雅的小问题
- Android开发之Animations(三)
- 交叉编译器的使用方法
- MW4530R 编译Openwrt全过程记录
- 首个微信小程序开发教程!
- 每个优秀程序员必须具备的技术技能
- Dear 素时雨
- [李景山php]每天laravel-20161201|BelongsToMany.php-4
- 关于使用Makefile进行GCC编译报错问题解决方法
- Python 练习册--存入数据库(Mongodb,MySQL)操作