Posted at

TextViewのテキストをObjectAnimatorでいじる

More than 1 year has passed since last update.

TextviewのsetTextの中で---をアニメーションで表すめも。

ObjectAnimatorを作るメソッド

 public static ObjectAnimator addHyphen(TextView targetView) {

ObjectAnimator objectAnimator = ObjectAnimator.ofObject(targetView, "Text", new TypeEvaluator() {
@Override
public Object evaluate(float fraction, Object startValue, Object endValue) {
return (fraction < 0.5) ? startValue : endValue;
}
}, "-", "--", "---");
objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
objectAnimator.setDuration(3000L);
return objectAnimator;
}

呼び出し側

ObjectAnimator objectAnimator = addHyphen(textView);

objectAnimator.start();
~~
objectAnimator.cancel();

これで------となるアニメーション作れる。



http://stackoverflow.com/questions/8227899/objectanimator-using-charsequence-setters