code: @Override
    public boolean onGenericMotionEvent(MotionEvent event) {
      if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
          case MotionEvent.ACTION_SCROLL: {
            if (!mIsBeingDragged) {
              final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
              final float hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
              if (vscroll != 0) {
                final int verticalScrollRange = getVerticalScrollRange();
                final int horizontalScrollRange = getHorizontalScrollRange();
                int oldScrollY = getScrollY();
                int oldScrollX = getScrollX();
                int newScrollY = (int) (oldScrollY - vscroll);
                int newScrollX = (int) (oldScrollX - hscroll);
                if (newScrollY < 0) {
                  newScrollY = 0;
                } else if (newScrollY > verticalScrollRange) {
                  newScrollY = verticalScrollRange;
                }
                if (newScrollX < 0) {
                  newScrollX = 0;
                } else if (newScrollX > horizontalScrollRange) {
                  newScrollX = horizontalScrollRange;
                }
                if (newScrollY != oldScrollY || newScrollX != oldScrollX) {
                  super.scrollTo(newScrollX, newScrollY);
                  return true;
                }
              }
            }
          }
        }
      }
      return super.onGenericMotionEvent(event);
    }
docs: INPUT & ACCESSIBILITY