@@ -15,11 +15,13 @@ public class ScrollView extends ViewGroup {
1515 private final double [] scroll = new double [2 ];
1616 private final Point space = new Point ();
1717 private final Point pixelScroll = new Point ();
18+ private final Point downMousePosition = new Point ();
1819 private final ScrollContainer container ;
1920 private Drawable scrollDrawable = new ColorDrawable (Color .GREEN );
2021 private final Point mouseScroll = new Point ();
2122 private boolean capturedMouseScroll = true ;
2223 private final Rect scrollbar = new Rect ();
24+ private long lastMouseEvent ;
2325
2426 public ScrollView (Context context ) {
2527 super (context );
@@ -81,11 +83,17 @@ protected boolean dispatchMouseEvent(MouseEvent mouseEvent) {
8183 mouseEvent .setTarget (hashCode ());
8284 return true ;
8385 }
84- } else if (mouseEvent .getTarget () == hashCode ()) {
85- double percent = mouseEvent .getY () / getMeasuredHeight ();
86+ } else if (mouseEvent .getTarget () == hashCode () && mouseEvent .getAction () == MotionEvent .ACTION_DOWN ) {
87+ if (lastMouseEvent != mouseEvent .getDownTime ()) {
88+ lastMouseEvent = mouseEvent .getDownTime ();
89+ downMousePosition .set ((scrollbar .height ()-((int ) mouseEvent .getY ()-scrollbar .top )), (int ) mouseEvent .getY ()-scrollbar .top );
90+ return true ;
91+ }
92+ double percent = (mouseEvent .getY ()) / (getMeasuredHeight ()-downMousePosition .x );
8693 percent = Math .max (0 , Math .min (1.0 , percent ));
8794 scroll [1 ] = percent ;
8895 measureContent ();
96+ measureContent ();
8997 return true ;
9098 }
9199
0 commit comments