Detecting plagiarism made easy.

Score: 0.800988495349884; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-10-02
by Masoud Mokhtari

Original Post

Original - Posted on 2019-04-13
by Ahmed na

Present in both answers; Present only in the new answer; Present only in the old answer;

Try this:
RecyclerView rv = findViewById(; LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, true); rv.setLayoutManager(layoutManager); rv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ListView to intercept touch events. v.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ListView to intercept touch events. v.getParent().requestDisallowInterceptTouchEvent(false); break; } // Handle HorizontalScrollView touch events. v.onTouchEvent(event); return true; } });
That code prevent scroll vertically when you scroll with your horizontal recyclerview.
if any one still looking , try this :
private val Y_BUFFER = 10 private var preX = 0f private var preY = 0f
mView.rv.addOnItemTouchListener(object : RecyclerView.OnItemTouchListener { override fun onTouchEvent(p0: RecyclerView, p1: MotionEvent) {
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent): Boolean { when (e.action) { MotionEvent.ACTION_DOWN -> rv.parent.requestDisallowInterceptTouchEvent(true) MotionEvent.ACTION_MOVE -> { if (Math.abs(e.x - preX) > Math.abs(e.y - preY)) { rv.parent.requestDisallowInterceptTouchEvent(true) } else if (Math.abs(e.y - preY) > Y_BUFFER) { rv.parent.requestDisallowInterceptTouchEvent(false) }
} } preX = e.x preY = e.y return false }
override fun onRequestDisallowInterceptTouchEvent(p0: Boolean) { } })
it checks if currently scrolling horizontal then don't allow parent to handel event

Present in both answers; Present only in the new answer; Present only in the old answer;