Android: Moving buttons freely in Eclipse's Graphical Layout Editor

20,278

Solution 1

The reason for iPhone absolute layouts is that all the screens are the same size. Because there is such a wide variety of android devices, you should try getting used to relative and linear layout construction.

To answer, no, you won't be able to place a button in an exact pixel location using the graphical layout editor.

Solution 2

  • you can (or need) to use the XML layout file to "layout" your buttons and whatnot.

Yes, you can use an xml layout. It's not required, though, as you can also create the whole UI in java.

  • So this means I have to use tables right?

No, there are many layouts available to choose from.

  • Is there a way that I can just freely move a button where I want with my mouse using the graphical layout editor in eclipse?

No, you can't in Eclipse. You can code it and see how it changes it's location in the layout preview. The AbsoluteLayout is deprecated due to the problems it causes with all the different screen sizes around.

The best alternative option is to master the RelativeLayout. It is a very powerful layout that will let you position your UI widgets anywhere in the screen while at the same time makes it easy to support multiple screen sizes.

Solution 3

Try clicking with the second mouse button on the layout. Change the layout. And then choose AbsoluteLayout.

Share:
20,278
faul
Author by

faul

Updated on December 25, 2020

Comments

  • faul
    faul over 3 years

    I've developed several iPhone apps and now I'm porting them onto Android.

    From what I was used to, I was able to freely move buttons around using the Interface Editor for the iPhone, and from what I understand for Android, you can (or need) to use the XML layout file to "layout" your buttons and whatnot.

    So this means I have to use tables right? Is there a way that I can just freely move a button where I want with my mouse using the graphical layout editor in eclipse?

    I've Googled and came upon this thread WYSIWYG View Editor in 'Android'? but I don't think they came up with a good conclusion..

    Thanks.

    -Paul

  • faul
    faul almost 13 years
    Thanks for the suggestion, I'll look into the RelativeLayout.
  • Thomas
    Thomas over 11 years
    AbsoluteLayout has been deprecated for a long time. As the documentation says: Absolute layouts are less flexible and harder to maintain than other types of layouts without absolute positioning.