You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The child gesture region calculation includes this code:
val coordinates = intArrayOf(0, 0)
view.getLocationInWindow(coordinates)
val x = coordinates[0]
val y = coordinates[1]
val absoluteRight = x + right
val absoluteBottom = y + bottom
viewIdToGestureRegionMap[view.id] = Rect(
x,
y,
absoluteRight,
absoluteBottom
)
This code is only correct in calculating the child's "region" if the top and left of the child is 0. Otherwise the calculation is wrong. Specifically it calculates the absoluteRight and absoluteBottom as absoluteRight = x + right and absoluteBottom = y + bottom.
However the right and bottom of a view is left + width and top + height respectively. So in essence it's calculating absoluteRight as absoluteRight = x + left + width and thus it's accounting for how far left the view is twice. Once in x and again in left. The correct calculations should be:
val coordinates = intArrayOf(0, 0)
view.getLocationInWindow(coordinates)
val x = coordinates[0]
val y = coordinates[1]
val width = right - left
val height = bottom - top
val absoluteRight = x + width
val absoluteBottom = y + height
viewIdToGestureRegionMap[view.id] = Rect(
x,
y,
absoluteRight,
absoluteBottom
)
The text was updated successfully, but these errors were encountered:
The child gesture region calculation includes this code:
This code is only correct in calculating the child's "region" if the top and left of the child is 0. Otherwise the calculation is wrong. Specifically it calculates the
absoluteRight
andabsoluteBottom
asabsoluteRight = x + right
andabsoluteBottom = y + bottom
.However the
right
andbottom
of a view isleft + width
andtop + height
respectively. So in essence it's calculatingabsoluteRight
asabsoluteRight = x + left + width
and thus it's accounting for how far left the view is twice. Once inx
and again inleft
. The correct calculations should be:The text was updated successfully, but these errors were encountered: