Reputation: 21
A mouse cursor can appear on Android TV when mouse is connected. How can I let cursor show without using real mouse?
Upvotes: 2
Views: 2775
Reputation: 2945
Since you've mentioned Android 4.0+ you are probably referring to the system native cursor. I have no idea on how to trigger it without using an external mouse, however what you can do is to draw an overlay cursor. The overlay is a special kind of window, that can be made to appear on top of all other. By doing so, and by adding a simple mouse cursor image, you would get ...a mouse cursor without using a real mouse. If this is what you need, and have to implement the code to do this, keep in mind the following:
The important steps in implementation are:
Prepare the window overlay parameters as:
WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT);
This would make your cursor appear like:
Hope this helps. You can also find a complete sample implementation at: http://www.pocketmagic.net/2012/07/android-overlay-cursor/
Upvotes: 1