Android ValueAnimator interpolating crazy colors

85 views Asked by At

I'm trying to use a very simple code to fade the background color change in a textview

the idea is to chose a new color, than have it fade from transparent to the desired color, here is the code:

 ValueAnimator anim = new ValueAnimator();


        anim.setEvaluator(ArgbEvaluator.getInstance());
        anim.setDuration(1500);
         
        anim.setIntValues(hightlightColor & 0x00FFFFFF, hightlightColor);
        // txtView.setBackgroundColor(hightlightColor);

        anim.addUpdateListener(animation -> txtView.setBackgroundColor((int) animation.getAnimatedValue()));
        anim.start();

highlight color is just a green i'm using for example, txtview is a valid textview and the current background is null

but instead of creating a fade in shades of green the code results in a crazy rainbow like interpolation, that ends exactly in the desired green, but all intermediate values are shit

I thought it might be the alpha channel so i tested starting from white to green but the intermediate colors were all crazy also

MY APP MINSDK IS 16 SO I CANT USE ValueAnimator.ofArgb()

here is how it looks

enter image description here

0

There are 0 answers