I\'m developing an Android 2.2.2 application which will support multiple screens sizes and all screens will be portrait. I won\'t support landscape.
I have test the foll
Indeed, the advice you received was good: it's possible to have only one layout file, but as it was already suggested in comments, it's not good to hardcode dimensions, even if you use dp
or dip
, specially when you are targeting all the screen sizes and densities available.
Instead, you should replace those values with links to dimensions values.
For example, instead of android:layout_marginLeft="10dp"
, you'll have something like
android:layout_marginLeft="@dimen/textview_margin_left"
where textview_margin_left is defined in the dimens.xml, having different values in different folders;
probably in folder values:
,
in folder values-large:
,
while in values-xlarge:
But this is just an example, you have to test on all dimensions and resolutions and find the best values for your layout. In Eclipse, in Graphical Layout
mode, you can easily get an idea about how your layout looks on various devices, just by clicking on Nexus One, and choosing another model from the list, and the layout will automatically update.
Also, you can move in dimens.xml
all the text sizes, and that will be very useful for x-large devices.
Using only one RelativeLayout
instead many imbricated LinearLayouts
might also be a good idea, and using relative positioning for your objects, instead some of the hardcoded values.