Different Layouts For Different Screen Sizes On Android?

Cistoran picture Cistoran · Jun 27, 2011 · Viewed 20.4k times · Source

So I made an app using in Eclipse using the Graphical Editor, AbsoluteLayout, fixed pixel values, etc... just bad practice in general. It defaulted to a 3.7in screen. Is there any way to design a separate layout for each screen size and have the program choose which to load based on said screen size?

Answer

cV2 picture cV2 · Jul 24, 2011

Provide different layouts for different screen sizes By default, Android resizes your application layout to fit the current device screen. In most cases, this works fine. In other cases, your UI might not look as good and might need adjustments for different screen sizes. For example, on a larger screen, you might want to adjust the position and size of some elements to take advantage of the additional screen space, or on a smaller screen, you might need to adjust sizes so that everything can fit on the screen.
The configuration qualifiers you can use to provide size-specific resources are small, normal, large, and xlarge. For example, layouts for an extra large screen should go in layout-xlarge/.

Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use the sw<N>dp configuration qualifier to define the smallest available width required by your layout resources. For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it in layout-sw600dp/. Using the new techniques for declaring layout resources is discussed further in the section about Declaring Tablet Layouts for Android 3.2.

From the Android developer site - just use layout-small/ layout-xlarge/ etc.. folder :=) best way ever..