app view上修改鼠标样式比较简单,使用如下方法修改为自定义图片:
getWindow().getDecorView().setPointerIcon(PointerIcon.load(getResources(), R.drawable.pointer_spot_touch_icon));
设置鼠标样式setPointerIcon的调用栈
@frameworks/base/core/java/android/view/View.javaView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes)case R.styleable.View_pointerIcon:
@frameworks/base/core/java/android/view/View.javasetPointerIcon(PointerIcon.getSystemIcon(context, pointerType));mPointerIcon = pointerIcon;
@frameworks/base/services/core/java/com/android/server/wm/Session.java mAttachInfo.mSession.updatePointerIcon(mAttachInfo.mWindow);
@frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.javamService.updatePointerIcon(window);
@frameworks/base/core/java/android/view/ViewRootImpl.javawindowUnderPointer.mClient.updatePointerIcon(windowUnderPointer.translateToWindowX(mouseX), windowUnderPointer.translateToWindowY(mouseY));