android - How to Use Collapsing ToolBar with a ListView instead of a Recycler View -
does know how implement collapsing toolbar using listview instead of recycler view?
to make woks should to:
implement nestedscrollingchild in custom listview implementation.
add field
private final nestedscrollingchildhelper mscrollingchildhelper;
, init in constructorsdelegate methods nestedscrollingchild
invoke
setnestedscrollingenabled(true);
aftermscrollingchildhelper
initialization
here list view implementation example:
public class nestedscrollinglistview extends listview implements nestedscrollingchild { private final nestedscrollingchildhelper mscrollingchildhelper; public nestedscrollinglistview(context context) { super(context); mscrollingchildhelper = new nestedscrollingchildhelper(this); setnestedscrollingenabled(true); } public nestedscrollinglistview(context context, attributeset attrs) { super(context, attrs); mscrollingchildhelper = new nestedscrollingchildhelper(this); setnestedscrollingenabled(true); } @override public void setnestedscrollingenabled(boolean enabled) { mscrollingchildhelper.setnestedscrollingenabled(enabled); } @override public boolean isnestedscrollingenabled() { return mscrollingchildhelper.isnestedscrollingenabled(); } @override public boolean startnestedscroll(int axes) { return mscrollingchildhelper.startnestedscroll(axes); } @override public void stopnestedscroll() { mscrollingchildhelper.stopnestedscroll(); } @override public boolean hasnestedscrollingparent() { return mscrollingchildhelper.hasnestedscrollingparent(); } @override public boolean dispatchnestedscroll(int dxconsumed, int dyconsumed, int dxunconsumed, int dyunconsumed, int[] offsetinwindow) { return mscrollingchildhelper.dispatchnestedscroll(dxconsumed, dyconsumed, dxunconsumed, dyunconsumed, offsetinwindow); } @override public boolean dispatchnestedprescroll(int dx, int dy, int[] consumed, int[] offsetinwindow) { return mscrollingchildhelper.dispatchnestedprescroll(dx, dy, consumed, offsetinwindow); } @override public boolean dispatchnestedfling(float velocityx, float velocityy, boolean consumed) { return mscrollingchildhelper.dispatchnestedfling(velocityx, velocityy, consumed); } @override public boolean dispatchnestedprefling(float velocityx, float velocityy) { return mscrollingchildhelper.dispatchnestedprefling(velocityx, velocityy); } }
Comments
Post a Comment