继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

ObjectAnimator

米脂
关注TA
已关注
手记 492
粉丝 88
获赞 591

透明度

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

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP