Reputation: 31096
Is there a way in Android to simulate a mouse pointer, what I mean by that is : I want to display a mouse pointer on my app, and move it to certain locations by giving it [x,y] so user can see where the mouse is pointing to ?
In Java Swing, I could use a robot and it can do "mouseMove(int x, int y)", nothing similar in Android ?
Upvotes: 0
Views: 658
Reputation: 23
You could use an animation set, you will want to get your screen coordinates another way this was a hack solution for a college class
private AnimationSet fullAnimation;
// some onCreate for a view
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setting the AnimationSet
fullAnimation = new AnimationSet(true);
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
int moveSize1 = (int) (width / 2.80);
int moveSize2 = (int) (height / 3.7);
int moveSize3 = (int) (width / 3.3);
int moveSize4 = -1*(int) (height / 1.7);
int moveSize5 = (int) (width / 2.85);
move1 = new TranslateAnimation(0, moveSize1, 0,0);
move1.setDuration(5000);
move1.setFillAfter(true);
fullAnimation.addAnimation(move1);
move2 = new TranslateAnimation(0,0,0,moveSize2);
move2.setDuration(5000);
move2.setFillAfter(true);
move2.setStartOffset(6000);
fullAnimation.addAnimation(move2);
Upvotes: 1