Share via


View.OnHoverEvent(MotionEvent) Method

Definition

Implement this method to handle hover events.

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

Parameters

e
MotionEvent

The motion event that describes the hover.

Returns

True if the view handled the hover event.

Attributes

Remarks

Implement this method to handle hover events.

This method is called whenever a pointer is hovering into, over, or out of the bounds of a view and the view is not currently being touched. Hover events are represented as pointer events with action MotionEvent#ACTION_HOVER_ENTER, MotionEvent#ACTION_HOVER_MOVE, or MotionEvent#ACTION_HOVER_EXIT.

<ul> <li>The view receives a hover event with action MotionEvent#ACTION_HOVER_ENTER when the pointer enters the bounds of the view.</li> <li>The view receives a hover event with action MotionEvent#ACTION_HOVER_MOVE when the pointer has already entered the bounds of the view and has moved.</li> <li>The view receives a hover event with action MotionEvent#ACTION_HOVER_EXIT when the pointer has exited the bounds of the view or when the pointer is about to go down due to a button click, tap, or similar user action that causes the view to be touched.</li> </ul>

The view should implement this method to return true to indicate that it is handling the hover event, such as by changing its drawable state.

The default implementation calls #setHovered to update the hovered state of the view when a hover enter or hover exit event is received, if the view is enabled and is clickable. The default implementation also sends hover accessibility events.

Java documentation for android.view.View.onHoverEvent(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

See also