Search code examples
javaandroidscrolltextviewandroid-scrollview

Scroll to particular Text view inside the Scroll view


There is a program generated scroll view like this:

The scroll view XML is just simple empty LinearLayout

<ScrollView>
<LinearLayout>
</LinearLayout>
</ScrollView>

Then , in the run time , I have an ArrayList<TextView>, and add the items to the ScrollView like this

for (TextView t : test_views) {
     scroll_view.addView(t);
}

And now , I have one of the listView and I would like to scroll to that TextView programmatic , the case is quite special so that can not change the scrollview to listview, how to achieve that?

Thanks a lot for helping.


Solution

  • Try using scrollTo() function. More details available in this link http://developer.android.com/reference/android/widget/ScrollView.html#scrollTo(int, int)