Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLocationOnScreen() off by half the button width #23

Open
Alchete opened this issue Oct 15, 2014 · 0 comments
Open

getLocationOnScreen() off by half the button width #23

Alchete opened this issue Oct 15, 2014 · 0 comments

Comments

@Alchete
Copy link

Alchete commented Oct 15, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant