• 15

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Reduce speed of smooth scroll in scroll view

I have a scroll View. I performed smooth-scroll.using smoothScrollBy().It all works fine, but I want to change the duration of the smooth-scroll. Smooth-scroll happens very fast and user is not understanding what happened.Please help me reduce smooth-scroll speed?

The simple answer is just to replace

scrollView.smoothScrollTo(0, scrollTo);


ObjectAnimator.ofInt(scrollView, "scrollY",  scrollTo).setDuration(duration).start();

where duration is the time in milliseconds you want it to take.

  • 171
Reply Report

Try the following code:

    ValueAnimator realSmoothScrollAnimation = 
        ValueAnimator.ofInt(parentScrollView.getScrollY(), targetScrollY);
    realSmoothScrollAnimation.addUpdateListener(new AnimatorUpdateListener()
        public void onAnimationUpdate(ValueAnimator animation)
            int scrollTo = (Integer) animation.getAnimatedValue();
            parentScrollView.scrollTo(0, scrollTo);

    parentScrollView.smoothScrollTo(0, targetScrollY);
  • 13
Reply Report
    • Instead of using ValueAnimator, why not use ObjectAnimator (a subclass of ValueAnimator)? It makes it even easier - a one liner, in fact: ObjectAnimator.ofInt(scrollView, "scrollY", targetScrollY).setDuration(500).start();

This is how I achieved a smooth vertical scroll (like movie credits). This also allows the user to move the scroll up and down and allow it to continue scrolling when they let go. In my XML, I encapsulated my TextView inside of a ScrollView called "scrollView1". Enjoy!

    final TextView tv=(TextView)findViewById(R.id.lyrics);
    final ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView1);
    Button start = (Button) findViewById(R.id.button_start);
    Button stop = (Button) findViewById(R.id.button_stop);
    final Handler timerHandler = new Handler();
    final Runnable timerRunnable = new Runnable() {
        public void run() {
            scrollView.smoothScrollBy(0,5);         // 5 is how many pixels you want it to scroll vertically by
            timerHandler.postDelayed(this, 10);     // 10 is how many milliseconds you want this thread to run

    start.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
           timerHandler.postDelayed(timerRunnable, 0);

    stop.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
  • 3
Reply Report
whichScreen = Math.max(0, Math.min(whichScreen, getBase().getDocumentModel().getPageCount()-1));
mNextScreen = whichScreen;
final int newX = whichScreen * getWidth();
final int delta = newX - getScrollX();
//scroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta) * 2);
scroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta));
  • -2
Reply Report