animation 之动画时间的控制
来源:互联网 发布:淘宝售后怎么赚钱 编辑:程序博客网 时间:2024/06/01 08:05
Q群: 241359063 更精彩,欢迎共同走向创业学习之旅。
原创:kylin_zeng http://blog.chinaunix.net/uid/23795897.html在此感谢mars 老师的帮助。转载请注明原创出处,尊重他人的劳动成果。
1、Interpolator定义了动画变化的速率,有如下几种:
1.1 AccelerateDecelerateInterpolator:在动画开始以及结束的地方速率改变比较慢,中间加速。
1.2 AccelerateInterpolator:在动画开始的地方速率改变比较慢,然后加速。
1.3 DecelerateInterpolator: 减速。
1.4 CycleInterpolator: 动画循环播放特定的次数,速率改变沿着正弦曲线。
1.5 LinearInterpolator:动画以均匀的速率改变。
函数的调用:
14_animations04.rar
原创:kylin_zeng http://blog.chinaunix.net/uid/23795897.html在此感谢mars 老师的帮助。转载请注明原创出处,尊重他人的劳动成果。
1、Interpolator定义了动画变化的速率,有如下几种:
1.1 AccelerateDecelerateInterpolator:在动画开始以及结束的地方速率改变比较慢,中间加速。
1.2 AccelerateInterpolator:在动画开始的地方速率改变比较慢,然后加速。
1.3 DecelerateInterpolator: 减速。
1.4 CycleInterpolator: 动画循环播放特定的次数,速率改变沿着正弦曲线。
1.5 LinearInterpolator:动画以均匀的速率改变。
点击(此处)折叠或打开
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator" //加快动作
- android:shareInterpolator="true"> //这里的true表示下面的两个动作都使用同一个interpolator,
- // 2. 如果使用android:shareInterpolator="false" 那么就要为后面两个分别定义不同的动作。
-
- <alpha
- // 2. android:interpolator="@android:anim/decelerate_interpolator"
- android:fromAlpha="1.0"
- android:toAlpha="0.0"
- android:startOffset="500"
- android:duration="2000" />
- <rotate
- // 2. android:interpolator="@android:anim/accelerate_interpolator"
- android:fromDegrees="0"
- android:toDegrees="360"
- android:pivotX="50%"
- android:pivotY="50%"
- android:duration="2000" />
- </set>
函数的调用:
点击(此处)折叠或打开
- package mars.animation04;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.animation.AccelerateInterpolator;
- import android.view.animation.AlphaAnimation;
- import android.view.animation.Animation;
- import android.view.animation.AnimationSet;
- import android.view.animation.DecelerateInterpolator;
- import android.view.animation.RotateAnimation;
- import android.widget.Button;
- import android.widget.ImageView;
- public class MainActivity extends Activity {
- private Button button = null;
- private ImageView imageView = null;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- imageView = (ImageView) findViewById(R.id.imageViewId);
- button = (Button) findViewById(R.id.scaleButtonId);
- button.setOnClickListener(new AnimationButtonListener());
- }
- private class AnimationButtonListener implements OnClickListener {
- @Override
- public void onClick(View v) {
- /**
- * Animation animation =
- * AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha);
- * imageView.startAnimation(animation);
- */
- // 声明一个AnimationSet对象
- AnimationSet animationSet = new AnimationSet(false); //这里如果设置成false 就要单独为每一个添加Interpolator.
- AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
- alpha.setInterpolator(new DecelerateInterpolator()); //添加
- RotateAnimation rotate = new RotateAnimation(0, 360,
- Animation.RELATIVE_TO_SELF, 0.5f,
- Animation.RELATIVE_TO_SELF, 0.5f);
- rotate.setInterpolator(new AccelerateInterpolator()); // 添加
- animationSet.addAnimation(alpha);
- animationSet.addAnimation(rotate);
- animationSet.setDuration(2000);
- animationSet.setStartOffset(500);
- imageView.startAnimation(animationSet);
- }
- }
- }
14_animations04.rar
0
上一篇:animation 之xml控制
下一篇:animations 动画图片的播放
相关热门文章
- 欢迎时间的旅行在ChinaUnix博...
- 天天挂机手游
- 成功人生的十堂课
- 【新闻】加拿大推出快速移民通...
- 西游神魔决手游
- Android之开发环境搭建
- Android自定义View的实现...
- AndroidManifest.xml配置文件...
- Android源码调试方法详解...
- 不用vs和cygwin!Eclipse+cdt...
- 请问Linux默认shell的是什么 ...
- 谁能够帮我解决LINUX 2.6 10...
- 现在的博客积分不会更新了吗?...
- shell怎么读取网页内容...
- ssh等待连接的超时问题...
给主人留下些什么吧!~~
评论热议
0 0
- animation 之动画时间的控制
- 获取当前播放的animation动画时间
- Android Animation动画 控制动画的执行效果,速度等
- cocos2d animation 时间控制
- Unity3D之动画(Animation)的制作
- Android之动画Animation的使用
- Android之 Animation动画的使用
- CSS3 动画之animation
- CSS3之动画Animation
- Android之Animation动画
- fusioncharts 之animation动画
- 动画Animation之抛物线
- Animation之tween动画
- Libgdx之Animation 动画
- Animation动画之alpha
- css动画之animation
- CSS3之动画animation
- Unity之Animation动画
- animation 控件之代码控制
- Ubuntu文件系统层 系统启动过程详解
- 系统需求与功能需求有什么区别
- animation 之xml控制
- 1st_uC/OS-II Basic Programmers’Guide
- animation 之动画时间的控制
- animations 动画图片的播放
- 跟我一起学extjs5(06--使用图标字体来美化按钮)
- animations 之 对控件设置动画效果
- [LeetCode] Anagram
- 视图用法详解
- ramdisk.img
- animation listerner 在动画开始、重复、结束后设置通知
- 做组合动画
原创粉丝点击
热门IT博客