I am trying to develop an application that requires multi-screen support. I read an Android article on best practices for multi-screen support. In accordance with this article, we must follow 3 important things:
- Mention support for various screen sizes (large, medium, and small) and any density in AndroidManifest.xml.
- Place images with a resolution of 3 dpi (120, 160, 240) in 3 folders res / ldpi, res / mdpi and res / hdpi.
- In the layout, the size should be indicated in units of "dip". Then Android will take care of scaling itself.
I implemented all these points in my project. Images are correctly selected from the corresponding folders. But the layout of the controls is not the same.
eg. I launched the application on three emulators
1. Resolution 240 * 320 dpi 120.
2. Resolution 240 * 320 dpi 160.
3. Resolution 240 * 320 dpi 240.
(All emulators have the same resolution but different densities.)
The problem is that the position of the controls is not the same on all three emulators. In my opinion, if android: layout_marginLeft and android: layout_marginTop are mentioned in "dip", then this problem should not occur. As the emulator density increases, the controls are placed closer to the right.
Is it absolutely imperative that I provide layouts for all combinations of screen size and density, even if the layout is the same for all devices?
Did I miss some important point?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/bgd" android:scaleType="fitXY"> </ImageView> <ImageView android:id="@+id/wtButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/button" android:layout_marginLeft="170dip" android:layout_marginTop="9dip"></ImageView> <ImageView android:id="@+id/htButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/button2" android:layout_marginLeft="220dip" android:layout_marginTop="90dip"></ImageView> </RelativeLayout>
Images:

source share