Skip to content

Instantly share code, notes, and snippets.

@AB1209
Created November 22, 2018 07:52
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/783760d569251609b2f9cb795c6abf33 to your computer and use it in GitHub Desktop.
Save AB1209/783760d569251609b2f9cb795c6abf33 to your computer and use it in GitHub Desktop.
Custom ScrollView which observes vertically scrolling.
public class ObservableScrollView extends ScrollView {
private ScrollViewListener scrollViewListener = null;
public ObservableScrollView(Context context) {
super(context);
}
public ObservableScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ObservableScrollView(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