Apidemos之动画

动画制作的几种片断

转载请注明出处:http://blog.csdn.net/droyon/article/details/8689689

下面的案例代码不能运行,缺少辅助类,完整例子,请参照http://blog.csdn.net/hailushijie/article/details/8689249

1、
ValueAnimator bounceAnim = ObjectAnimator.ofFloat(sh, "y", startY,endY);

第一个参数为对象,第二个参数为要调整的对象中的某一属性,第三个参数为float... values,不定个数参数。

2、
bouncer.play(a).before(b);
bouncer.play(b).with(c);
bouncer.play(d).after(c);

before、with、以及after的关系。
先播放a,然后播放b,在播放b的过程中播放c,c播放完,播放d

3、
AnimatorSet bouncer = new AnimatorSet();
bouncer.play(squashAnim).with(fadeAnim);
bouncerSet.play(bounceAnim).before(bouncer);

4、
animation.playTogether(anim1, anim2, s1);//with
animation.playSequentially(s1, s2);//play s1 before s2

5、
ObjectAnimator anim2 = anim1.clone();
Clone复制 一份。
6、
动画开始
Animator.Start()
暂停
Animator.Cancel()
结束
Animator.End()
反转动画
ValueAnimator.reverse
设置播放位置
ValueAnimator.setCurrentPlayTime
7、加载配置文件:
//-----------------------------------------------------------------
ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.
                        loadAnimator(appContext, R.anim.object_animator);
anim.addUpdateListener(this);
anim.setTarget(balls.get(0));
配置文件内容:
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:valueTo="200"
    android:valueType="floatType"
    android:propertyName="y"
    android:repeatCount="1"
android:repeatMode="reverse"/>
//--------------------------------------------------------------
ValueAnimator fader = (ValueAnimator) AnimatorInflater.
                        loadAnimator(appContext, R.anim.animator);
                fader.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    public void onAnimationUpdate(ValueAnimator animation) {
                        balls.get(1).setAlpha((Float) animation.getAnimatedValue());
                    }
                });
配置文件内容:
<animator xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:valueFrom="1"
    android:valueTo="0"
    android:valueType="floatType"
    android:repeatCount="1"
    android:repeatMode="reverse"/>
//--------------------------------------------------------------
AnimatorSet seq =
                        (AnimatorSet) AnimatorInflater.loadAnimator(appContext,
                        R.anim.animator_set);
                seq.setTarget(balls.get(2));
配置文件:
<set>
    <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:valueTo="200"
        android:valueType="floatType"
        android:propertyName="x"
        android:repeatCount="1"
        android:repeatMode="reverse"/>
    <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:valueTo="400"
        android:valueType="floatType"
        android:propertyName="y"
        android:repeatCount="1"
        android:repeatMode="reverse"/>
</set>



你可能感兴趣的:(动画,ApiDemos)