Skip to content

Instantly share code, notes, and snippets.

@AB1209
Created November 22, 2018 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AB1209/ff86c1ccc4346e55e1f8319bd0e76e2c to your computer and use it in GitHub Desktop.
Save AB1209/ff86c1ccc4346e55e1f8319bd0e76e2c to your computer and use it in GitHub Desktop.
Custom ScrollView which observers horizontal scrolling.
public class ObservableHorizontalScrollView extends HorizontalScrollView {
private ScrollViewListener scrollViewListener = null;
public ObservableHorizontalScrollView(Context context) {
super(context);
}
public ObservableHorizontalScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ObservableHorizontalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setScrollViewListener(ScrollViewListener scrollViewListener) {
this.scrollViewListener = scrollViewListener;
}
@Override
protected void onScrollChanged(int x, int y, int oldx, int oldy) {
super.onScrollChanged(x, y, oldx, oldy);
if (scrollViewListener != null) {
scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment