I have a recycler view inside a ScrollView. I want to disable the recycler view scroll so that it listens to its parent layout, A ScrollView!
As setLayoutFrozen is deprecated, You can disable scrolling by freezing your RecyclerView by using suppressLayout . Show activity on this post. You can disable scrolling by freezing your RecyclerView.
setnestedscrollingenabled set it to false.
The problem can be solved by moving the SliverAppBar into the CustomScrollView and not use the NestedScrollView at all.
Just set your LayoutManager and adapter for the first time. Make a setDataList method in your adapter class. And set your updated list to adapter list. And then every time of calling API set that list to setDataList and call adapter.
Here using "isScrollEnabled" flag you can enable/disable scrolling functionality of your recycle-view temporarily. Simple override your existing implementation to disable scrolling and allow clicking. linearLayoutManager = new LinearLayoutManager (context) { @Override public boolean canScrollVertically () { return false; } };
Instead of returning true, and therefore disabling all sorts of touch events, just return e.getAction () == MotionEvent.ACTION_MOVE; instead of return true; so only scroll/swipe events get cancelled. As setLayoutFrozen is deprecated, You can disable scrolling by freezing your RecyclerView by using suppressLayout.
After that when I scroll down or go up the view back to its normal position like the changes that I made it’s gone from view. It is because RecyclerView recycles every view which is not visible to the user. So, when the user scrolls back it recycles the previous view which is in normal form.
So, when it is called we stored a flag value in our BokkModel class. Now when the user scrolls bottom or comes back to the previous position the view never changes. You can also add ClickListener on itemView when the user taps on the row you can change the background color and store in the model.
This should solve your RecyclerView nested scrolling.
mRecyclerView.setNestedScrollingEnabled(false);
RecyvlerView implements NestedScrollingChild
for instance if RecyclerView parent is a ScrollView or ListView or RecyclerView or any AbsListView
disable scrolling for the child RecyclerView.
Logically, it is not a good idea to put ListView
inside a ScrollView
. However, if you insist then:
ListView
height based on the sum of its
rows height as mentioned here.ListView
to redirect scrolling to its parent ScrollView as mentioned
here.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With