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
阅读(35) | 评论(0) | 转发(0) |
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
原创: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);
- }
-
- }
- }

相关热门文章
给主人留下些什么吧!~~
评论热议