Horizontal Recyclerview inside a Vertical Scrollview - android

I have a situation where I have a Recyclerview which slides horizontally inside a ScrollView. Now the situation is when I do a horizontal swipe on the Recyclerview, instead of scrolling the cardviews inside Recyclerview, it scrolls the screen up, which disturbs the user experience.
Any solution or approach to avoid vertical scrolling when the person is doing a horizontal swipe on Recyclerview?

The solution is actually quite simple.
put the horizontal RecycleView as an item in a RecycleView, instead of using a scrollview.
then when you scroll it behaves as you want it to.
Thats what I did and it works perfectly

Related

Scroll issue with RecyclerView in RecyclerView

I have a RecyclerView where each item is a linear layout (orientation vertical) with a text view and another horizontal RecyclerView. The expected behaviour would be that the user would be able to seamless change from vertical to horizontal scroll, but it appears if user tries to swipe horizontally while the vertical scroll is not entirely stopped (yet not visible move, just to swipe fast) or if the horizontal swipe starts somehow from a diagonal motion, the app keeps the vertical scroll and ignores the horizontal one.
Is there a best practice on how to use a vertical recyclerview with horizontal recyclerview items? Tried to search for this a lot, but nothing seems to work.

ViewPager within MotionLayout not scrolling correctly

I have a MotionLayout which basically contains an image and a ViewPager. The ViewPager renders a fragment with a RecyclerView in it.
At first the image has normal size, when i drag up, the image reduces its size and the ViewPager (with the RecyclerView within it) expands.
The problem is that the MotionLayout keeps intercepting the scroll action, so if the RecyclerView is expanded, and the user scrolls down, the MotionLayout will expand the image, rather than letting the RecyclerView scroll.
What i would expect is that the MotionLayout will expand the top image only if the RecyclerView has reached the first element, in that case since the RecyclerView cannot scroll anymore, the scroll action would be managed by the MotionLayout.
I am aware that within MotionLayout I can set the attribute moveWhenScrollAtTop="true" to get that behaviour, but that only works if there is just a RecyclerView, but not if the RecyclerView is within a ViewPager.
Has anyone faced this issue?
if your xml file contains nested scrollview just add android:nestedScrollingEnabled="false"

Space appears at the bottom of a Cardview when scrolling

I have a Recyclerview with a Cardview and inside there is another Recyclerview like Netflix. So I cann scroll vertical and horizontal. Insider the inner recyclerview there are some cardviews with buttons. My Problem is if I scroll down and up again, then there apears some Space inside the Carview.
How does this happen?
Start
After Scrolling
Any suggestion or idea is helpful.
Note: Without the Itemdecoration (Page Indikator) it works and no Space appears.

Horizontal RecyclerView inside ScrollView: how to get focus when vertical scrolling?

I have a ScrollView with multiple horizontal RecyclerView. The problem is this:
When I scroll vertically to navigate into my app and I touch on a recyclerview to scroll horizontally, the focus remain on the scrollview and I can't scroll horizontally. I have to release the finger and touch again in order to scroll vertically. I'd like to give proprity to the recyclerview, so I can scroll horizontally without stopping the vertical scroll.
I tried multiples solutions:
editing some parameters in the xml of the recyclerview and its container (focusable, focusableintouchmode, descendantFocusability,nestedscrollingenabled)
adding an ontouchlistener and intercepting the motionevent, both in scrollview and recyclerview
This problem is present using both ScrollView and NestedScrollview and using both RecyclerView and ListView
Thanks for your help
This problem because of recyclerView has default focus.
Just Add this
android:descendantFocusability="blocksDescendants"
to your immediate layout of scrollView.

Nested Horizontal view inside RecyclerView

I want Horizontal scrollable items in vertical recyclerView. horizontal items will not be more than 10 in any case.
I thought of two approaches
1) Horizontal Recyclerview as item in vertical RecyclerView
2) Custom horizontalScrollView as an item in vertical RecyclerView
I have implemented first one facing some issues in scrolling but I think I will manage that.
My question is, why not second approach. I have seen all related question on SO and most of them trying to do with first approach. Why is it so?
What is disadvantage? specially I you have limited number in horizontal view.
Any pointer would be great help.
Why do we use RecyclerView instead of LinearLayout?
Because if we use a LinearLayout consisting of (let's say 50 items) they will be all rendered on screen (50 Views) and this will lead to very very bad performance issues and scalability issues. RecyclerView does initialize the views that appears on screen only ,let's say 7 views, and they will be recycled in every new row that comes.
Why do we use Horizontal Recyclerview instead of Horizontal ScrollView?
This is not usually the case. If you have multiple items in every row that needs to be recycled then you should use Horizontal RecyclerView otherwise it won't matter at all.
To summarize,
The views in the vertical RecyclerView will got recycled whether it has another horizonal RecyclerView or Horizontal ScrollView, but the views inside the Horizontal ScrollView will not get recycled and the views inside the Horizontal RecyclerView will got recycled as it's a RecyclerView.
If you don't have multiple items in your Horizontal RecyclerView, you shall use Horizontal ScrollView instead.

Categories

Resources