Is it possible to support the setScrollY () function (ScrollView API 14), similar to the function for older API levels?

I have a simple first Android app that I encode. One of my main activities is ScrollView, which is quite long. In this case, I have a few buttons that invoke other ListViews. When the ListViews are finished and the ScrollView returns, I want the position on the screen to be the same as the first time the ListView was called.

I found the getScrollY () and setScrollY () methods and can implement them to maintain the position the way I want.

However, setScrollY () is an API function 14 and above, and according to the statistics of my application, I have many users on Gingerbread, which is an older API level.

My question is: is there a method that I have missed or I can point to this that allows me to have the same functions as setScrollY () on older API levels?

+5
source share
1 answer

Have you looked at scrollTo(getScrollX(), y)? It is available in all versions of Android.

http://developer.android.com/reference/android/view/View.html#scrollTo(int%2C%20int)

If you look at the implementation setScrollY(), you will see:

public void setScrollY(int value) {
    scrollTo(mScrollX, value);
}
+15
source

All Articles