Changing position of a button

前端 未结 4 1764
有刺的猬
有刺的猬 2020-12-03 18:45

I have one button in an AbsoluteLayout in an XML file. From there I am able to set the (x,y) position of the button.

How can I get and set the (x,y) coordinates of t

4条回答
  •  猫巷女王i
    2020-12-03 18:58

    You have to get a reference to you button, for example by calling findViewById(). When you got the reference to the button you can set the x and y value with button.setX() and button.setY().

    ....
    Button myButton = (Button) findViewById(R.id.);
    myButton.setX();
    myButton.setY();
    ....
    

提交回复
热议问题