Scroll issue with RecyclerView in RecyclerView - android

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.

Related

Change focus in RecyclerView in single vertical click

I am building an app for Android TV by using Nested RecyclerView. Root is vertical RecyclerView which has rows with Horizontal RecyclerView.
I want to change the focus on the single click and want to keep the scroll position static. But scrolling is always happening at the bottom of the view for horizontal and vertical both.
I am using the focus listener to scroll to top
verticalRLVLayout.scrollToPositionWithOffset(rowNumber,0);
horizantalRLVLayout.scrollToPositionWithOffset(columnNumber, 0);
This is not working always and i don't see this is the best option.
Is there any way by which if we have fixed height of each row the single click will change the focus always.
Going upward in the RecyclerView, causes new row to slide towards right and focus goes to last visible tile on the previous row. Why this is happening, any idea ?
Thanks

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"

Nested touch events

I have a horizontal RecyclerView. The items in that RecyclerView contain a vertical SeekBar. The RecyclerViewand the SeekBarscroll/slid fine, but it is inconvenient to move the SeekBar because a slight horizontal move results a scroll of the RecyclerView.
I want to disable the RecyclerView scroll when the user touches the SeekBar, or to reduce the sensibility of the RecyclerViewto a horizontal movement.

Horizontal Recyclerview inside a Vertical Scrollview

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

How to make a bi-directional RecyclerView?

I need to be able to make a bi-directional RecyclerView. Basically, it would scroll vertically, but each row would be a horizontal list of tiles that could scroll. The initial scroll position would be at the top and left. The user could scroll down, and scroll to the right with each row.
Any ideas on how to do this? (e.g. with a custom LayoutManager or touch event interception).
I was able to solve the issue using a custom view implementation.
At the root, I have a custom ScrollView; when onMeasure is called, the ScrollView tells its children how tall they should. In this case, they are half the height of the ScrollView. The width matches the height so they display as square tiles.
Each of the ScrollView children are RecyclerView's with a horizontal LinearLayoutManager. Since the ScrollView tells each child how tall to be, there's no issues with measurement and they actually scroll very well in both directions (vertically and horizontally).

Categories

Resources