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>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hailushijie

您的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值