I read quite a few of the questions posted here but I didnt get a clear answer to my question. Will using the unit dp take care of physical screen size? I have used the unit dp for all my Views and I have tried to make the sizes of them relative.But even then i had to give absolute sizes to some of them. Will the app run the same in a 4 inch as well as a 5 inch screen.Here is the structure :
Here is My XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="400dp" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_above="@+id/relativeLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/left" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/right" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:id="@+id/rel2"
android:layout_height="350dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout1" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:src="@drawable/lc" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="280dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout1"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView3"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="120dp"
android:layout_marginTop="140dp"
android:src="@drawable/untitled" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout2"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="64dp"
android:src="@drawable/lc" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
>
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/left" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignBottom="@+id/imageButton1"
android:layout_alignParentRight="true"
android:src="@drawable/right" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
</LinearLayout>
Thanks in advance....
No using dp we cant take care of diffrent screen size.
for that you need to use difftent strategy You can use
this will cover half of screen if you set
android:layout_width="0dp"
and two views are ina rowif you set height= 0dp it will cover half of the total height of screen
Note