View.RequestPointerCapture 方法

定义

请求指针捕获模式。

[Android.Runtime.Register("requestPointerCapture", "()V", "GetRequestPointerCaptureHandler", ApiSince=26)]
public virtual void RequestPointerCapture ();
[<Android.Runtime.Register("requestPointerCapture", "()V", "GetRequestPointerCaptureHandler", ApiSince=26)>]
abstract member RequestPointerCapture : unit -> unit
override this.RequestPointerCapture : unit -> unit
属性

注解

请求指针捕获模式。

当窗口具有指针捕获时,鼠标指针图标将消失,并且不会更改其位置。 启用指针捕获将通过以下方式更改输入设备的行为:<来自鼠标的 ul><li>事件将与源 InputDevice#SOURCE_MOUSE_RELATIVE一起传递,相对位置更改将通过 和 MotionEvent#getY提供。<MotionEvent#getX/李>

<来自触摸板或触控板的 li>事件将与源InputDevice#SOURCE_TOUCHPAD一起传递,其中触摸板上每个指针的绝对位置将通过 和 MotionEvent#getY(int)提供MotionEvent#getX(int),并且其相对移动存储在 和 MotionEvent#AXIS_RELATIVE_YMotionEvent#AXIS_RELATIVE_X。</李>

<来自>其他类型的设备(如触摸屏)的事件将不受影响。</li></ul>

指针捕获更改时,可能会重新配置连接的鼠标和触控板设备,并且其属性 (,例如其源或运动范围) 可能会更改。 android.hardware.input.InputManager.InputDeviceListener使用 在设备更改 (启用或禁用指针捕获) 后可能发生的通知,并使用 InputDevice#getDevice(int) 获取更新InputDevice的 。

如果OnCapturedPointerListener设置了 ,则通过指针捕获捕获的事件将调度到 OnCapturedPointerListener#onCapturedPointer(View, MotionEvent) ,否则将调度到 #onCapturedPointerEvent(MotionEvent)

如果窗口已有指针捕获,则此调用不执行任何操作。

捕获可能通过 #releasePointerCapture()释放,或者在窗口失去焦点时自动丢失。

android.view.View.requestPointerCapture()Java 文档。

此页面的某些部分是基于 创建和共享的工作进行的修改,并根据 署名许可中所述的条款使用。

适用于