javaandroidscrollviewandroid-scrollview

Can I scroll a ScrollView programmatically in Android?


Is there any way to scroll a ScrollView programmatically to a certain position?

I have created dynamic TableLayout which is placed in a ScrollView. So I want that on a specific action (like clicking a Button, etc.) the particular row should scroll automatically to a top position.

Is it possible?


Solution

  • ScrollView sv = (ScrollView)findViewById(R.id.scrl);
    sv.scrollTo(0, sv.getBottom());
    

    or

    sv.scrollTo(5, 10);