極客學(xué)院Animation教程講解的很詳細(xì),點擊進(jìn)入哦
這里為學(xué)習(xí)的整理和補充O(∩_∩)O
一震捣、xml中標(biāo)簽對應(yīng)的Animator
<animator />:對應(yīng) ValueAnimator
<objectAnimator />:對應(yīng) ObjectAnimator
<set />:對應(yīng) AnimatorSet
二、<animator />:對應(yīng) ValueAnimator
<animator
android:duration="int"
android:valueFrom="float | int | color"
android:valueTo="float | int | color"
//對應(yīng) startDelay(long delay)函數(shù)
android:startOffset="int"
android:repeatCount="int"
android:repeatMode=["repeat" | "reverse"]
android:valueType=["intType" | "floatType"]
android:interpolator=["@android:interpolator/XXX"]/>
ValueAnimator valueAnimator = (ValueAnimator) AnimatorInflater.loadAnimator(context,
R.animator.value_animator);
valueAnimator.start();
三闹炉、<objectAnimator />:對應(yīng) ObjectAnimator
<objectAnimator
android:propertyName="string"
android:duration="int"
android:valueFrom="float | int | color"
android:valueTo="float | int | color"
android:startOffset="int"
android:repeatCount="int"
android:repeatMode=["repeat" | "reverse"]
android:valueType=["intType" | "floatType"]
android:interpolator=["@android:interpolator/XXX"]/>
ObjectAnimator animator = (ObjectAnimator) AnimatorInflater.loadAnimator(context,
R.animator.object_animator);
animator.setTarget(mTv1);
animator.start();
四蒿赢、<set />:對應(yīng) AnimatorSet
<set
android:ordering=["together" | "sequentially"]>
<objectAnimator
android:propertyName="string"
android:duration="int"
android:valueFrom="float | int | color"
android:valueTo="float | int | color"
android:startOffset="int"
android:repeatCount="int"
android:repeatMode=["repeat" | "reverse"]
android:valueType=["intType" | "floatType"]/>
<animator
android:duration="int"
android:valueFrom="float | int | color"
android:valueTo="float | int | color"
android:startOffset="int"
android:repeatCount="int"
android:repeatMode=["repeat" | "reverse"]
android:valueType=["intType" | "floatType"]/>
<set>
...
</set>
</set>
AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(MyActivity.this,
R.animator.set_animator);
set.setTarget(mTv1);
set.start();
demo:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together">
<objectAnimator
android:propertyName="TranslationX"
android:duration="500"
android:valueFrom="0"
android:valueTo="400"
android:valueType="floatType"/>
<objectAnimator
android:propertyName="TranslationY"
android:duration="500"
android:valueFrom="0"
android:valueTo="300"
android:valueType="floatType"/>
</set>