listening to scroll events horizontalscrollview android

You may want to try creating your own custom class that extends HorizontalScrollView and overriding the onScrollChanged() function as such

public class TestHorizontalScrollView extends HorizontalScrollView {

    public TestHorizontalScrollView(Context context) {
        super(context);
    }


    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        // TODO Auto-generated method stub
        Log.i("Scrolling", "X from ["+oldl+"] to ["+l+"]");
        super.onScrollChanged(l, t, oldl, oldt);
    }

}

This overriden function will catch all changes to the scroll position even when the view is not being touched. This should keep your scroll views in sync.

Leave a Comment