1

I have a scroll view with a linear layout inside, which contains many text boxes.

Now I'm trying to build up an automatic scrolling, but I can't get the current scroll position of the layout.

How is this possible?

Thanks in advance

orelzion
  • 2,332
  • 3
  • 26
  • 40

1 Answers1

-1

Check out this answer, I think it's the thing you're looking for: https://stackoverflow.com/a/3035521/375929

Edit:

How about doing this:

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putInt("scrollX", scrollView.getScrollX());
    outState.putInt("scrollY", scrollView.getScrollY());
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    int scrollX = savedInstanceState.getInt("scrollX"); // Defaults to 0
    int scrollY = savedInstanceState.getInt("scrollY");
    scrollView.scrollTo(scrollX, scrollY);
}
Community
  • 1
  • 1
Ivan Bartsov
  • 16,024
  • 6
  • 54
  • 57