Udostępnij za pośrednictwem


ViewGroup.OnInterceptHoverEvent(MotionEvent) Method

Definition

Implement this method to intercept hover events before they are handled by child views.

[Android.Runtime.Register("onInterceptHoverEvent", "(Landroid/view/MotionEvent;)Z", "GetOnInterceptHoverEvent_Landroid_view_MotionEvent_Handler")]
public virtual bool OnInterceptHoverEvent (Android.Views.MotionEvent? e);
[<Android.Runtime.Register("onInterceptHoverEvent", "(Landroid/view/MotionEvent;)Z", "GetOnInterceptHoverEvent_Landroid_view_MotionEvent_Handler")>]
abstract member OnInterceptHoverEvent : Android.Views.MotionEvent -> bool
override this.OnInterceptHoverEvent : Android.Views.MotionEvent -> bool

Parameters

e
MotionEvent

The motion event that describes the hover.

Returns

True if the view group would like to intercept the hover event and prevent its children from receiving it.

Attributes

Remarks

Implement this method to intercept hover events before they are handled by child views.

This method is called before dispatching a hover event to a child of the view group or to the view group's own #onHoverEvent to allow the view group a chance to intercept the hover event. This method can also be used to watch all pointer motions that occur within the bounds of the view group even when the pointer is hovering over a child of the view group rather than over the view group itself.

The view group can prevent its children from receiving hover events by implementing this method and returning true to indicate that it would like to intercept hover events. The view group must continuously return true from #onInterceptHoverEvent for as long as it wishes to continue intercepting hover events from its children.

Interception preserves the invariant that at most one view can be hovered at a time by transferring hover focus from the currently hovered child to the view group or vice-versa as needed.

If this method returns true and a child is already hovered, then the child view will first receive a hover exit event and then the view group itself will receive a hover enter event in #onHoverEvent. Likewise, if this method had previously returned true to intercept hover events and instead returns false while the pointer is hovering within the bounds of one of a child, then the view group will first receive a hover exit event in #onHoverEvent and then the hovered child will receive a hover enter event.

The default implementation handles mouse hover on the scroll bars.

Java documentation for android.view.ViewGroup.onInterceptHoverEvent(android.view.MotionEvent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to