gummy714 gummy714 - 1 year ago 112
Android Question

In Android Studio is it possible to set the position of a button in a layout via java code?

I'm currently working on a game that has buttons changing positions. I was wondering how I could change the buttons position in a GridLayout via java code

Answer Source

Why don't you just simply change the X and Y.

Button myButton = (Button) findViewById(;
myButton.setX(<x value>);
myButton.setY(<y value>);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download