tags:

views:

366

answers:

2

How can we resize our application for different screens on different Android devices?

+4  A: 

If you want your layouts to work on different resolution screens your should be sizing them using dip as the unit. For example:

android:layout_marginRight="10dip"

dip stands for Device Independent Pixel and using these in your layout means that Android will automatically scale your layout depending on which display the device running your application has.

You can read about these in the Supporting Multiple Screens page in the Android Developer Documentation. This document also has some other options for handling different displays but I think using dip is probably the easiest.

Dave Webb
A: 

yes, as Dave answered, using "dip" is the best way to go.

Also, some screens have different ratio of Heigth/Width, so using only "dip" will not be enough. Then you have 2 options. If you always use Layouts like LinearLayout, RelativeLayout, etc with "fill parent", you will be fine because the screen will grow. But sometimes you set a fixed height on something, and if you deploy it on the droid (for example) it will look short because the droid has more height/width ratio than the G1/G2/etc In that case you will need to set the height using code.

Daniel Benedykt