Q:

Imageview reveal animation

Im trying to setup an imageview that reveals it's image overtime (horizontally)
I have it working right now by extending ImageView and in the onDraw. Taken from CoveredImageView
@Override
protected void onDraw(Canvas canvas) {

    canvas.getClipBounds(mRect);
    int i = round((float) mRect.width() * mPercent);
    mRect.right = i + mRect.left;
    canvas.clipRect(mRect);

    super.onDraw(canvas);
    invalidate();

}

mPercent is the amount i want to show, i have it hooked up to a music player and seekbar and reveal like this
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        revealImg.updatePercent((float) progress / (float) seekBar.getMax());
    }
}

Everything works well when the timer/song duration is long like < 10min as it reveals slowly, but if the song is like 1min the reveal isn't a smooth animation (image is same width as the device) it like jumps since it needs to show the whole image in a smaller amount of time (hopefully you understand what i mean)
I know why it's doing thing, im thinking because the clipRect in the onDraw is showing pixel per pixel so if the song is 30sec and the device is ex 300px wide it jumps 10px each second, where as a 10min song would only be .5px rounded to 1px(not as noticeable)
Im wondering if anyone has a better approach to make it not choppy. Im thinking I could maybe use ValueAnimator but im not quite sure how to use it to reveal an imageview.

A:

Figured it out, using ValueAnimator!
I just replaced
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    revealImg.updatePercent((float) progress / (float) seekBar.getMax());
}

with
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    float value = (float) animation.getCurrentPlayTime();
     revealImg.updatePercent(value / mixDurationInMilli);
}

Everything is much smoother now :) Im just not quite sure why... :/

