Skip to content

Instantly share code, notes, and snippets.

@AB1209
Created November 22, 2018 07:58
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/a7168232caee881a8faf6abd917833a2 to your computer and use it in GitHub Desktop.
Save AB1209/a7168232caee881a8faf6abd917833a2 to your computer and use it in GitHub Desktop.
ScrollTest activity, impleming ScrollViewListenere
public class ScrollTest extends Activity implements ScrollViewListener {
private ObservableScrollView scroll_vertical_from_both;
private ObservableScrollView scroll_vertical_only;
private ObservableHorizontalScrollView scroll_horizontal_from_both;
private ObservableHorizontalScrollView scroll_horizontal_only;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scrolltest);
scroll_vertical_from_both = (ObservableScrollView) findViewById(R.id.scroll_vertical_from_both);
scroll_vertical_only = (ObservableScrollView) findViewById(R.id.scroll_vertical_only);
scroll_horizontal_from_both = (ObservableHorizontalScrollView) findViewById(R.id.scroll_horizontal_from_both);
scroll_horizontal_only = (ObservableHorizontalScrollView) findViewById(R.id.scroll_horizontal_only);
scroll_vertical_from_both.setScrollViewListener(this);
scroll_vertical_only.setScrollViewListener(this);
scroll_horizontal_from_both.setScrollViewListener(this);
scroll_horizontal_only.setScrollViewListener(this);
}
@Override
public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {
Log.i("", "VERTICAL");
scroll_vertical_from_both.scrollTo(x, y);
scroll_vertical_only.scrollTo(x, y);
}
@Override
public void onScrollChanged(ObservableHorizontalScrollView scrollView, int x, int y, int oldx, int oldy) {
Log.i("", "HORIZONTAL");
scroll_horizontal_from_both.scrollTo(x, y);
scroll_horizontal_only.scrollTo(x, y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment