Reputation: 1500
I have a horizontal scrolling recyclerview
. The recyclerviews
child items have slide up panel. So when the panel is expanded i want to block recyclerview
scrolling.
Till the slide up panel is expanded the user cannot scroll to next item. Once the slide up panel is collapsed then the recyclerview
scrolling should be enabled.
This is recyclerview
initialization code
mAdapter = new FootballFeedDetailAdapter(FootballFeedDetailActivity.this);
linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(mAdapter);
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(footballFeedRecyclerView);
I tried using recyclerView.setNestedScrollingEnabled(false);
But it is not working
from my adapter if the slideup panel is expanded i am colling the below method
public void setUpRecyclerViewScroll(boolean status) {
footballFeedRecyclerView.setNestedScrollingEnabled(status);
}
Thanks in advance. I will be very helpful if someone answers this.
Upvotes: 1
Views: 398
Reputation: 1881
Extend LinearLaoyutManager and override canScrollHorizontally
method.
When your slideup panel is expanded/collapsed call the layoutmanager setScrollingEnabled(false/true)
private static class HScrollManager extends LinearLayoutManager {
private boolean scrollingEnabled = true;
public void setScrollingEnabled(boolean enabled) {
scrollingEnabled = enabled;
}
@Override
public boolean canScrollHorizontally() {
return scrollingEnabled && super.canScrollVertically();
}
}
Upvotes: 2