gummy714
gummy714

Reputation: 35

Set the position of a button in a layout via Java

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

Upvotes: 0

Views: 56

Answers (1)

android_Muncher
android_Muncher

Reputation: 1057

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

Button myButton = (Button) findViewById(R.id.YourButtonIDInXML);
myButton.setX(<x value>);
myButton.setY(<y value>);

Upvotes: 2

Related Questions