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
The Problem is following you use in your layout, static values (100dp, 60dp). Now the problem is on a higher resolution this dp isn't the same.
That means you should create a layout for x-large screens. Also I wouldn't use those static values. Than your application will behave good on many diffrent screensizes!
Have a great Day
safari
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: <dimen name="textview_margin_left">10dp</dimen>
,
in folder values-large: <dimen name="textview_margin_left">20dp</dimen>
,
while in values-xlarge: <dimen name="textview_margin_left">30dp</dimen>
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.