I have a Recyclerview inside another RecyclerView, the inner recyclerview item views are clickable. When I click any item view in the inner recyclerview, it is not scroll to top, I tried using scrollToPosition(position) and scrollTo(X, Y) methods but no luck. I guess I have to scroll the outter recyclerview to achieve it, but don't know how to scroll parent recyclerview from child recyclerview. Can somebody help me on this?
Regards,
Rajapandian.
Related
I'm trying to design a row list using RecyclerView like Android TV ↳ android.support.v17.leanback.widget.ListRow. I'm able to design list with title but not row list. Can anyone help me?
Please Follow this Link for
Recycer view like play store
Use Two RecyclerView Outer Recycler is vertical and Second horizontal recycler is item of first recycler View
All you need is to call mInnerRecycler.setNestedScrollingEnabled(false); on your inner RecyclerViews and use Horizontal scrollview as root of mInnerRecyclerView
Explanation:
RecyclerView has support for nested scrolling introduced in API 21 through implementing the NestedScrollingChild interface. This is a valuable feature when you have a scrolling view inside another one that scrolls in the same direction and you want to scroll the inner View only when focused.
In any case, RecyclerView by default calls RecyclerView.setNestedScrollingEnabled(true); on itself when initializing. Now, back to the problem, since both of your RecyclerViews are within the same ViewPager that has the AppBarBehavior, the CoordinateLayout has to decide which scroll to respond to when you scroll from your inner RecyclerView; when your inner RecyclerView's nested scrolling is enabled, it gets the scrolling focus and the CoordinateLayout will choose to respond to its scrolling over the outer RecyclerView's scrolling. The thing is that, since your inner RecyclerViews don't scroll vertically, there is no vertical scroll change (from the CoordinateLayout's point of view), and if there is no change, the AppBarLayout doesn't change either.
In your case, because your inner RecyclerViews are scrolling in a different direction, you can disable it, thus causing the CoordinateLayout to disregard its scrolling and respond to the outer RecyclerView's scrolling.
Notice:
The xml attribute android:nestedScrollingEnabled="boolean" is not intended for use with the RecyclerView, and an attempt to use android:nestedScrollingEnabled="false" will result in a java.lang.NullPointerException so, at least for now, you will have to do it in code.
RecyclerView can check View Type for return header or item. And use layout manager for manage how to item scrolling direction.
RecyclerView (vertical scrolling)
- item -> RecyclerView (horizontal scrolling) check view type is header or item with condition example : is object has type header
Ref : Google play store like interface using recycler view
I have a nested recyclerview and both have a horizontal linear layout but the child one is not scrolling
All consequences
1) I'm using a snap helper in the parent recyclerview
2) also using recycler view pool in child recyclerview
It is bad practice to use a Nested RecyclerView with the same LayoutManager.
If horizontal scrolling is important to use for you then try RecyclerView inside ViewPager.
This will behave like this:
When scrolling RecyclerView, Fragment will stick to port until RecyclerView last item is shown. After that the next fragment switchs.
Context
I have a nested Recyclerview like the following sketch shows you:
In the drawing you can see a RecyclerView, which in turn holds one RecyclerView each as item.
Question
My question now is: How can I get the outer, parent Recyclerview scroll to a position of one of the child RecyclerViews. In the drawing I marked you Content pos 5 as my target position for example the Child RecyclerView 2.
What I already found out
One approach I've been thinking about was using scrollToPositionWithOffset(position, offset) on the parent RecyclerView, then just scroll to the position of the child RecyclerView 2 and then have the offset as the size of the list of items in the Child RecyclerView. But how can I get the size when the view isn't even inflated?
I would be very happy if one of you could give me some help that also ran into this problem of scrolling to a position of the child RecyclerView in such a nested Recyclerview.
As we know we have option ListView.TRANSCRIPT_MODE_ALWAYS SCROLL which will scroll to bottom.
The list will automatically scroll to the bottom, no matter what items
are currently visible.
Now we are having RecyclerView, does there any similar option of this in RecyclerView?
You can use
recycler_view.scrollToPosition(int position);
where position is index of row in recycle view.
I have a RecyclerView, and each ViewHolder has another RecyclerView. However only the parent RecyclerView gets focus and the child RecyclerView does not ever get any focus.
I need the child to get focus so it can scroll. Has anyone managed to do that?