Search code examples
androidbuttontextcolor

Android Button Text Color Animation


I have a button. I want to create a color animation for button text. How can I do it? How can ı use ObjectAnimator?


Solution

  • I use;

    ObjectAnimator colorAnim = ObjectAnimator.ofInt(button, "textColor",getResources().getColor(R.color.colorPrimaryDark),getResources().getColor(R.color.colorPrimary));
                colorAnim.setDuration(1000);
                colorAnim.setEvaluator(new ArgbEvaluator());
                colorAnim.setRepeatCount(ValueAnimator.INFINITE);
                colorAnim.setRepeatMode(ValueAnimator.REVERSE);
                colorAnim.start();