Scroll Up ScrollView Slowly

Question: "How to scroll ScrollView to the top is very smooth and slow."

In my special case, I need to scroll up in about 1-2 seconds. Ive tried to manually interpolate using Handler (calling scrollTo (0, y)), but that didn't work at all.

I saw this effect on some book applications, so there must be a way, I'm sure: D. (The text scrolls very slowly to continue reading without touching the screen, making input).

+8
android scroll scrollview
source share
5 answers

After 2 seconds, move the scroll view to position 2000

new CountDownTimer(2000, 20) { public void onTick(long millisUntilFinished) { scrolView.scrollTo((0, (int) 2000 - millisUntilFinished)); } public void onFinish() { } }.start(); 
+10
source share

I did this with an object animator (available in API> = 3) and it looks very good:

Define ObjectAnimator: final ObjectAnimator animScrollToTop = ObjectAnimator.ofInt(this, "scrollY", 0);

( this refers to a class extending Android ScrollView )

You can set its duration as you wish:

animScrollToTop.setDuration(2000); (2 seconds)

Ps Do not forget to start the animation.

+25
source share

Try using the following code:

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ValueAnimator realSmoothScrollAnimation = ValueAnimator.ofInt(parentScrollView.getScrollY(), targetScrollY); realSmoothScrollAnimation.setDuration(500); realSmoothScrollAnimation.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int scrollTo = (Integer) animation.getAnimatedValue(); parentScrollView.scrollTo(0, scrollTo); } }); realSmoothScrollAnimation.start(); } else { parentScrollView.smoothScrollTo(0, targetScrollY); } 
+9
source share

Have you tried smoothScrollTo(int x, int y) ? You cannot set the speed parameter, but perhaps this function will be ok for you.

+4
source share

You can use the Timer and TimerTask class. You could do something like

 scrollTimer = new Timer(); scrollerSchedule = new TimerTask(){ @Override public void run(){ runOnUiThread(SCROLL TO CODE GOES HERE); } }; scrollTimer.schedule(scrollerSchedule, 30, 30); 
0
source share

All Articles