Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 318
faul Avatar asked Jun 03 '11 19:06

faul


2 Answers

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.

like image 71
John Leehey Avatar answered Sep 20 '22 20:09

John Leehey


  • 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.

like image 41
Aleadam Avatar answered Sep 22 '22 20:09

Aleadam