问题
I use Webview, which loads random sites. For good navigation I need to turn on the mouse cursor, which will be controlled by D-pad, but I did not find information on how to do it, maybe someone can have developed such navigation, I will be grateful for any help.
回答1:
Use pointer capture
A view in your app can request pointer capture only when the view hierarchy that contains it has focus. For this reason, you should request pointer capture when there's a specific user action on the view, such as during an onClick()
event, or in the onWindowFocusChanged()
event handler of your activity.
To request pointer capture, call the requestPointerCapture()
method on the view. The following code example shows how to request pointer capture when the user clicks a view:
来源:https://stackoverflow.com/questions/64350673/how-to-programmatically-include-the-mouse-cursor-in-android-tv