i'am work on a app and i need start fuction on scroll webview to end.

This code set function on scroll to top

webView.setOnScrollChangeListener(new View.OnScrollChangeListener() {

@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
int diff = (v.getBottom() - (v.getHeight() + v.getScrollY()));
  if (diff == 0) {
     fab.show();
  } else {
     fab.hide();
  }
 }
});

How to change this to set fucnction on bottom?

1 Answers

0
Amol Gharpure On

You can use a NestedScrollView on a setOnScrollChangeListener

NestedScrollView scroller = (NestedScrollView) findViewById(R.id.myScroll);

    if (scroller != null) {

        scroller.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {

                if (scrollY > oldScrollY) {
                    System.out.println("Scroll DOWN");
                }
                if (scrollY < oldScrollY) {
                    System.out.println("Scroll UP");
                }

                if (scrollY == 0) {
                    System.out.println("TOP SCROLL");
                }

               if (scrollY == ( v.getMeasuredHeight() - v.getChildAt(0).getMeasuredHeight() )) {
                   System.out.println("BOTTOM SCROLL");
               }
           }
        });
    }