Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: HorizontalScrollView smoothScroll animation time

I have a situation in that I am using a horizontal scroll view with images and using buttons to smooth scroll to the different image locations. Now it works okay I was just wondering if anyone knew of anyway to slow down the smooth scroll method, i.e. having a longer annimation time? As currently the snapping happens pretty quickly.

Perhaps through an override of the smoothscroll, I have tried to search for this/examples but to no luck.

So any ideas?

Thanks,

Si

like image 330
somin Avatar asked Mar 04 '11 12:03

somin


2 Answers

How About:

ObjectAnimator animator=ObjectAnimator.ofInt(yourHorizontalScrollView, "scrollX",targetXScroll );
animator.setDuration(800);
animator.start();
like image 103
Saikat Avatar answered Nov 12 '22 17:11

Saikat


THis is one way, which works well for me:

    new CountDownTimer(2000, 20) { 

        public void onTick(long millisUntilFinished) { 
            hv.scrollTo((int) (2000 - millisUntilFinished), 0); 
        } 

        public void onFinish() { 

        } 
     }.start();

So here the horizontal scroll view (hv) moves in two seconds from position 0 to 2000 or to the end of the view if smaller than 2000px. Easy to adjust...

like image 15
Lumis Avatar answered Nov 12 '22 18:11

Lumis