Created
July 5, 2018 17:51
-
-
Save Alec-DeSouza/c571a1f8dc9f57e1d99a2b9877f9916c to your computer and use it in GitHub Desktop.
RecyclerView compatible with scrolling and ViewPager swiping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StoppableRecyclerView(context: Context, attrs: AttributeSet?, defStyle: Int) | |
: RecyclerView(context, attrs, defStyle) { | |
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) | |
constructor(context: Context) : this(context, null, 0) | |
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean { | |
if(e?.action == MotionEvent.ACTION_DOWN) { | |
stopNestedScroll() | |
stopScroll() | |
} | |
return super.onInterceptTouchEvent(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment