Recyclerview smooth horizontal scroll inside Scrollview

I’m trying to achieve an effect like the landing page of the Google Play store. I believe the hierarchy is this:

  • CoordinatorLayout
  • Scrollview
  • Recyclerview with Horizontal Linearayout

The horizontal scrolling in the "New + Updated Games" section is incredibly smooth and does not interfere with vertical scrolling. In my implementation, there is a movement up and down during the swipe, and therefore the effect is not smooth.

Ideally, only for explicit UP or DOWN gestures if the view is up or down.

Do I understand correctly? Is there any tutorial or guide that helps me achieve the same effect?

enter image description here

+5
source share
3 answers

I would really appreciate it if you could add code snippets to better understand your problem. Although, here is an excerpt

{ recyclerView.setHasFixedSize(true); linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, true); linearLayoutManager.setReverseLayout(false); linearLayoutManager.setStackFromEnd(false); adapter = new RecyclerAdapter(getContext(), arrayList); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(adapter); recyclerView.setNestedScrollingEnabled(false); adapter.notifyDataSetChanged(); } 
+1
source

If I understand your question correctly, you have a parent scroll view and you have a child image of a horizontal scroll / scroll recirculator, so just do it with your recirculation overview.

 addOnItemTouchListener(new OnItemTouchListener() { @Override public boolean onInterceptTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN && recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_SETTLING){ recyclerView.stopScroll(); } return false; } @Override public void onTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) { } @Override public void onRequestDisallowInterceptTouchEvent(boolean b) { } }); 

If you have more than 1 viewer, do the same with other viewers. And if that helps, don't forget to raise your voice

0
source

Viewpager

Hello,

I don’t think you need to use Recyclerview, I suggest you use View Pager to achieve this function. This will solve your problem.

0
source

Source: https://habr.com/ru/post/1238781/


All Articles