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

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.

Related

How to delegate scroll of RecycleView to ScrollView

I have a RecyclerView inside ScrollView. I want RecyclerView to start scrolling itself only after it reached a top of the screen, and while it isn't it should scroll his parent ScrollView. How to achieve this behavior?
use widget nestedscrollview or
recyclerview scroll display and scrollview enable
recyclerView.setNestedScrollingEnabled(false);

MapView inside scrollview is not scrolling vertically which is inside Fragment

I have one Fragment and in that I have taken mapview which is inside ScrollView.
While Scrolling the mapview It doesn't scrolling vertically due to it is inside ScrollView, But It scrolls horizontally.
How to avoid this Problem ?
You can add this line on your scrollview in order to allow only vertical scrolling.
android:scrollbars="vertical"

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).

Adding dynamic content to ScrollView causes jerk to bottom

I have implemented my own ScrollView that detects when the position of the ScrollView is close to the bottom and add views as necessary. The problem is when I add views to the LinearLayout inside of the ScrollView the scroll jerks to the bottom where I added some views. Is there anyway to add views to a LinearLayout inside a ScrollView that will not cause this behavior?
Thanks
Edit: This seems to only happen while scrolling. I have a case where I add views to the same ScrollView but by clicking a button rather than scrolling and I don't have the jerking problem. The new views just get added to the bottom of the LinearLayout being scrolled.

Categories

Resources