Skip to content Skip to sidebar Skip to footer

Scrollview Autoscrolling

First of all let me excuse for this question, I know that many other people asked it here, but I am so stupid that did not find any correct answer for me. I have a ScrollView and m

Solution 1:

you can use a scroller to create a smooth animation of the scroll. there's an example here: Android: Scroller Animation?

basically, all you need to do is start the scroller from 0 to the end of the list and call the scrollTo of the list with the scroller value.

another option is to create a timer that calls scrollBy every time.

EDIT: also, the way you created CountDownTimer causes it to run for 2000 milliseconds, and call onTick every 1ms. If you want it to run longer, just increase the overall time. I also suggest using a bigger interval - 1ms is way too often for display purposes. Try this:

new CountDownTimer(10000, 25) { 
     publicvoidonTick(long millisUntilFinished) { 
     h.scrollBy(1,0);
}

Solution 2:

You can also use ObjectAnimator to achieve this:

ObjectAnimator.ofInt(view, "scrollY", 0, view.getBottom).setDuration(1000).start;

Post a Comment for "Scrollview Autoscrolling"