faizmalkani / Fabulous

[DEPRECATED]
MIT License
478 stars 117 forks source link

getLocationOnScreen() off by half the button width #23

Open Alchete opened 9 years ago

Alchete commented 9 years ago

I'm trying to move the button programmatically, which works fine, but I'm running into an issue when querying getLocationOnScreen(). The returning values appear to be off by half of the button width.

You should be able to see the issue with the following code:

// Set the button location int mLocation[] = new int[2]; mButton.setX(200); mButton.getLocationOnScreen(mLocation); . . // Elsewhere (triggered in an onClick callback), try: mButton.setX(mLocation[0]);

When I do this, the button jumps to the right, in error by half the width of the button.

I believe the error lies in the getLocation() measurement and not the setX() call, as I can set the x-location to the edge of the screen correctly.

Do you have any idea what would cause an error in the getLocation measurement? I'm guessing there's an issue in the widget correctly reporting it's size?

Any help would be greatly appreciated. And, thank you for the library.