The best way I found how to do this is using the .setTranslateX() and .setTranslateY(). The number of pixels is passed as the parameters. I called my button "button" (because it's obvious), so in my code I typed
This puts the button in the center, top half of the window.
I know this question was asked 6 days ago when this answer appears, but I hope it helps!