Managing Android layouts should be the best way

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

Basically, I should have a portrait and landscape layout for regular, small and large screens. So, for this you need to save 6 layouts, not to mention the need to run the application on three emulators each time, because my user interface widgets are not loaded into the built-in preview.

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

Are there any tools to support Android layouts?

thanks

+6
android android-layout
source share
4 answers

You do not need to have many layouts. Create only as much as you need and never use absolute values, and try to do everything well, using fill_parent and wrap_content for your layouts layout_width and layout_height. Android does most of its work. This article contains a lot of useful information: Multi-screen support

+8
source share

You may find this application useful for developing your layouts:

http://www.droiddraw.org/

In addition, if you do not specify a layout for each rotation, the android will use one - infact, it can use it for everything. If you use fixed values, this makes it a lot more complicated. Try using fill_parent and wrap_content, you android will take care of scaling the view for each type of screen and rotation too.

As a hint, be sure 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 location and:

 </ScrollView> 

at the end - so if the view does not fit on the screen (i.e. too much content), it will allow the user to scroll.

+1
source share

Eclipse, the built-in layout editor, provides a pretty good example of what the layout looks like. Suppose you are writing your application in Eclipse. If not, I highly recommend it. Although not perfect, this is the best environment I've found.

0
source share

you just need to learn the proper use of RelativeLayout and LinearLayout . Almost all of my layouts will start with Relative and Linear nested inside. I usually don’t use LinearLayouts without having a height or width of 0, and using the weight attribute to make everything the same.

0
source share

All Articles