I have been trying to set the initial position of a scroll View but have not found a way. Does anyone have any ideas? Also I have a GoogleMaps fragment as a children of the
The accepted answer is not working for me. There is no direct way to set the initial position of a scroll view.
However, you can set the initial position before drawing the scroll view, like this:
rootView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
scrollView.getViewTreeObserver().removeOnPreDrawListener(this);
scrollView.setScrollY(100);
return false;
}
});
You can also use scrollView.setScrollY(100)
inside Handler
, but that will be jerky while scrolling.