I am trying to develop an app for which I want multiple screen support. I have read the Android article on Best practices for Multiple Screen Support. As per the article we have to follow 3 important things:
- Mention support for different screen sizes(large, medium and small) and any density in AndroidManifest.xml.
- Place images of 3 dpi's (120, 160, 240) in 3 folders res/ldpi, res/mdpi and res/hdpi.
- In layout's the dimension should be mentioned in "dip" units. Then Android will take care of the scaling on its own.
I have implemented all these points in my project. The images are picked up correctly from the appropriate folders. But the arrangements of the controls in not same.
e.g. I ran the app on three emulators
1. Resolution 240*320 dpi 120.
2. Resolution 240*320 dpi 160.
3. Resolution 240*320 dpi 240.
(All the emulator have same resolution but different density. )
The problem is the position of the controls is not same on all the three emulator. As per my understanding if the android:layout_marginLeft and android:layout_marginTop are mentioned in "dip" then this problem should not occur. As the density of the emulator increases the controls get placed more towards the right.
Is it absolutely necessary that i provide layouts for all combination's of screen dimension and density even if the layout is same for all the devices?
Am I missing 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: