views:

117

answers:

5

Hi, I'm trying to sort the layout for one of my Android apps, but I'm finding layouts a nightmare.

Principally I have to have a portrait and landscape layout for normal, small and large screens. So thats 6 layouts to maintain to start with, let alone having to launch the app on three emulators each time because my UI widets don't load in the built in previewer.

I might be showing my ignorance as a fairly new developer, but there must be a better way!

Are there any tools out there to help with Android layouts?

Thanks

+4  A: 

You dont need to have that many layouts. Design only as many as you need, and never use absolute values, aditionally try to make everything look nice using fill_parent and wrap_content for you layout_width & layout_height tags. Android does most of the work it self. This article contains a lot of usefull info: Supportng multiple screens

blindstuff
+1  A: 

You may find this applicaiton helpful for designing your layouts:

http://www.droiddraw.org/

Also, if you don't specify a layout for each rotation, android will use one - infact it can use one for everything. If you use fixed values it makes it much harder. Try using fill_parent and wrap_content, you android will take care of scaling the view for each screen type and rotation too.

As a tip, don't forget to include:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

above your relative or linear layout, and:

</ScrollView>

at the end - that way if the view doesn't fit on the screen (ie too much content) it will allow the user to scroll.

Scoobler
In my experience using droid draw, its a great tool to do some basic design work just to get a mock up or basic layout idea, but the best way to edit the layout is still old fashion text editing the XML. Since list views and dynamically generated content is a big thing in android these things dont show up unless you are runing the app and hence droidraw wont give you the full picture.
blindstuff
A: 

Eclipse's built in layout "editor" shows a reasonably good example of what a layout looks like. I would assume you're writing your application in Eclipse. If not, I highly recommend it. While not perfect, it's the best environment I've found.

Dave
A: 

you just need to master the proper use of RelativeLayout's and LinearLayout's. Almost all of my Layouts will start with a Relative and have Linear nested inside. I generally don't use LinearLayouts without having either height or width set to 0 and using the weight attribute to make everything the same size.

schwiz
A: 

Not yet ready, but may be of interest: Basic4android visual designer

Erel