implement View.getLocationInWindow() and MotionEvent.offsetLocation()

This is needed for NestedScrollViews to detect and correct parent scroll offset
This commit is contained in:
Julian Winkler
2024-03-27 22:50:58 +01:00
parent 8f770d38d1
commit 9b9e046d68
2 changed files with 8 additions and 2 deletions

View File

@@ -1636,6 +1636,8 @@ public final class MotionEvent extends InputEvent {
ev.action = other.action;
ev.coord_x = other.coord_x;
ev.coord_y = other.coord_y;
ev.raw_x = other.raw_x;
ev.raw_y = other.raw_y;
return ev;
}
@@ -2731,7 +2733,9 @@ public final class MotionEvent extends InputEvent {
*/
public final void offsetLocation(float deltaX, float deltaY) {
if (deltaX != 0.0f || deltaY != 0.0f) {
nativeOffsetLocation(mNativePtr, deltaX, deltaY);
// nativeOffsetLocation(mNativePtr, deltaX, deltaY);
this.coord_x += deltaX;
this.coord_y += deltaY;
}
}

View File

@@ -1115,7 +1115,9 @@ public class View extends Object {
return new IBinder();
}
public void getLocationInWindow(int[] xxx) {}
public void getLocationInWindow(int[] location) {
getLocationOnScreen(location);
}
public void addOnAttachStateChangeListener(OnAttachStateChangeListener l) {}