Skip to content

Instantly share code, notes, and snippets.

@BlaShadow
Created June 13, 2014 19:51
Show Gist options
  • Save BlaShadow/10da21d7b7b96005d31f to your computer and use it in GitHub Desktop.
Save BlaShadow/10da21d7b7b96005d31f to your computer and use it in GitHub Desktop.
Scroll list view into scrollview
ListView lv = (ListView)findViewById(R.id.myListView); // your listview inside scrollview
lv.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle ListView touch events.
v.onTouchEvent(event);
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment