在xml中使用屬性動畫
阿新 • • 發佈:2019-01-01
xml中定義屬性動畫
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectAnimator android:duration="1000" android:propertyName="scaleX" android:valueFrom="1.0" android:valueTo="2.0" android:valueType="floatType"> </objectAnimator> <objectAnimator android:duration="1000" android:propertyName="scaleY" android:valueFrom="1.0" android:valueTo="2.0" android:valueType="floatType"> </objectAnimator> <objectAnimator android:duration="1000" android:propertyName="alpha" android:valueFrom="0.1" android:valueTo="1" android:valueType="floatType"> </objectAnimator> </set>
java程式碼中載入屬性動畫
private void animatorXml(){
Animator animator = AnimatorInflater.loadAnimator(this,R.animator.scale_animator);
animator.setTarget(mImage);
animator.start();
}