LoginSignup
2
2

More than 5 years have passed since last update.

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

Posted at

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

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2