简体   繁体   中英

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 threadWYSIWYG View Editor in 'Android'? but I don't think they came up with a good conclusion..

Thanks.

-Paul

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM