android - How to disable RecyclerView scrolling? -
i cannot disable scrolling in recyclerview
. tried calling rv.setenabled(false)
can still scroll.
how can disable scrolling?
you should override layoutmanager of recycleview this. way disable scrolling, none of ther other functionalities. still able handle click or other touch events. example:-
original:
public class customgridlayoutmanager extends linearlayoutmanager { private boolean isscrollenabled = true; public customgridlayoutmanager(context context) { super(context); } public void setscrollenabled(boolean flag) { this.isscrollenabled = flag; } @override public boolean canscrollvertically() { //similarly can customize "canscrollhorizontally()" managing horizontal scroll return isscrollenabled && super.canscrollvertically(); } }
here using "isscrollenabled" flag can enable/disable scrolling functionality of recycle-view temporarily.
also:
simple override existing implementation disable scrolling , allow clicking.
linearlayoutmanager = new linearlayoutmanager(context) { @override public boolean canscrollvertically() { return false; } };
Comments
Post a Comment