tried :
nestedscrollview ns =(nestedscrollview) findviewbyid(r.id.nested_scroll); ns.setonscrollchangelistener(new nestedscrollview.onscrollchangelistener() { @override public void onscrollchange(nestedscrollview v, int scrollx, int scrolly, int oldscrollx, int oldscrolly) { } }); but got stuck, have idea?
just clearify want - want able observe scroll state (as in addonscrolllistener of recyclerview) , check once, when scrolling has ended (idle), if user scrolled end of nestedscrollview.
unfortunately, nestedscrollview not support implementation dispatches scroll state, because totally different kind of scroll view. framelayout scroller.
usually, end of scroll view reached when viewcompat.canscrollvertically (scrollview, -1) returns false. scroll state need subclass nestedscrollview , add own interface similar 1 of recyclerview. interface method should called in following overriden methods:
stopnestedscroll() -> scroll_state_idle
startnestedscroll() -> scroll_state_dragging
dispatchnestedprefling() -> scroll_state_flinging
please don't forget make super calls of these methods. if don't break nestedscrollview behavior
edit:
public class nestedscrollingview extends nestedscrollview { private int mstate = recyclerview.scroll_state_idle; public interface nestedscrollviewscrollstatelistener { void onnestedscrollviewstatechanged(int state); } public void setscrolllistener(nestedscrollviewscrollstatelistener scrolllistener) { this.mscrolllistener = scrolllistener; } private nestedscrollviewscrollstatelistener mscrolllistener; public nestedscrollingview(context context) { super(context); } public nestedscrollingview(context context, attributeset attrs) { super(context, attrs); } public nestedscrollingview(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); } @override public void stopnestedscroll() { super.stopnestedscroll(); dispatchscrollstate(recyclerview.scroll_state_idle); } @override public boolean onstartnestedscroll(view child, view target, int nestedscrollaxes) { dispatchscrollstate(recyclerview.scroll_state_dragging); return super.onstartnestedscroll(child, target, nestedscrollaxes); } @override public boolean startnestedscroll(int axes) { boolean superscroll = super.startnestedscroll(axes); dispatchscrollstate(recyclerview.scroll_state_dragging); return superscroll; } private void dispatchscrollstate(int state) { if (mscrolllistener != null && mstate != state) { mscrolllistener.onnestedscrollviewstatechanged(state); mstate = state; } } }