Skip to content

Instantly share code, notes, and snippets.

@sakurabird
Last active January 13, 2021 23:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakurabird/6868909 to your computer and use it in GitHub Desktop.
Save sakurabird/6868909 to your computer and use it in GitHub Desktop.
AndroidのScrollViewの中でもうまくGridViewのScrollを効かす
mGridView = (GridView) getView().findViewById(R.id.spotsView);
mGridView.setOnTouchListener(new GridView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// ScrollViewの中でもうまくGridViewのScrollを効かす
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
v.onTouchEvent(event);
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment