手记

ObjectAnimator

透明度

alphaanimator = ObjectAnimator.ofFloat(textView, "alpha", 1, 0, 1);

alphaanimator.setDuration(3*1000);

alphaanimator.start();

旋转:

rotationanimator = ObjectAnimator.ofFloat(textView, "rotation", 0, 360, 0);

rotationanimator.setDuration(3*1000);

rotationanimator.start();

大小:

scaleanimator = ObjectAnimator.ofFloat(textView, "scaleX", 0.5f, 1);

scaleanimator.setDuration(3*1000);

scaleanimator.start();

背景色:

bgcoloranimator = ObjectAnimator.ofInt(textView, "BackgroundColor", 0xffff00ff, 0xff00ff22);

bgcoloranimator.setEvaluator(new ArgbEvaluator());

bgcoloranimator.setDuration(3*1000);

bgcoloranimator.start();

XML文件:

ObjectAnimator xmlAnimator = (ObjectAnimator) AnimatorInflater.loadAnimator(ObjectAnimatorActivity.this, R.animator.objectanimator);

xmlAnimator.setTarget(textView);

xmlAnimator.start();

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" 

    android:propertyName="translationX"

    android:interpolator="@android:anim/accelerate_decelerate_interpolator"

    android:duration="3000"

    android:valueType="floatType"

    android:valueFrom="300"

    android:valueTo="-300"/>

propertyobjectanimat:

Property<TextView, Float> property = new Property<TextView, Float> (Float.class, "rotation") {

@Override

public void set(TextView object, Float value) {

object.setRotation(value.floatValue());

}

@Override

public Float get(TextView object) {

return object.getRotation();

}

};

ObjectAnimator propertyAnimator = ObjectAnimator.ofFloat(textView, property, 90, 360, 180, 0);

propertyAnimator.setDuration(3*1000);

propertyAnimator.start();

break;

原文链接:http://www.apkbus.com/blog-880881-63287.html

0人推荐
随时随地看视频
慕课网APP