ScrollView auto scroll to show content in app screen

While displaying long text data or displaying data in lot of views, we use ScrollView to view whole screen by scrolling. At times we may require app to auto Scroll down in a screen to show a bottom content.

If you try using below code in Activity’s OnCreate method to scroll down in ScrollView

ScrollView mScrollView = (ScrollView) findViewById(;

It won’t scroll. Since the layout is not yet done adding all views and you call fullScroll immediately after instantiating the ScrollView.

Solution for ScrollView to auto scroll down

auto scroll

To solve this issue, A short delay gives, the system enough time to settle. You have to use following code to set the delay

mScrollView.postDelayed(new Runnable() {
    public void run() {
       //replace this line to scroll up or down
}, 100L);

voila, you can see app Scroll down to bottom of screen.

Similarly, If you want to set Scroll to top of screen, in above run() method replace line with

mScrollView.scrollTo(0, 0);

If you are using HorizotalScrollView, and if you want to move to right end of screen, use following code..

mHorizontalScrollView.postDelayed(new Runnable() {
    public void run() {
}, 100L);

here mHorizontalScrollView is object of HorizantalScrollView.

Hope it helps somebody.


You may be also interested in


  1. snehal waman | | Reply

    Good Work..It runs perfectly..Thank you..

    • suresh | | Reply

      plz send total code

  2. aksahy labhshetwar | | Reply

    working fine

Leave a Reply

Your email address will not be published. Required fields are marked *