Search code examples
androidxmlscrollviewgame-physicsautoscroll

Android scrollview: scroll down automatically over a period of time


I am currently working on an app, this one: http://90kids.com/level-dash/ and i can't figure out how to make my screen scroll automatically like ther. Any help is appreciated


Solution

  • Create timer task scroll your view after each particular time. Refer Below example

    Timer timer = new Timer();
                TimerTask doAsynchronousTask = new TimerTask() {       
                    @Override
                    public void run() {
                        handler.post(new Runnable() {
                            public void run() {       
                ScrollView sv =(ScrollView)findViewById(R.id.scrl);
                sv.scrollTo(0, 10);
                            }
                        });
                    }
                };
                timer.schedule(doAsynchronousTask, 0, 100000);