here is my code. This same code is installed in many device and layout is not same in all.I have used relative layout and have drag and drop object. But even if you dragand drop object, the code should work finely in all devices.
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/room1"
android:background="@drawable/room1"
android:layout_above="@+id/textView8"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/load"
android:background="@drawable/load1"
android:layout_above="@+id/textView10"
android:layout_alignLeft="@+id/textView2"
android:layout_alignStart="@+id/textView2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About"
android:id="@+id/appbutton"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/textView10"
android:layout_alignEnd="@+id/textView10" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/employee"
android:background="@drawable/employee"
android:layout_above="@+id/textView8"
android:layout_alignLeft="@+id/textView8"
android:layout_alignStart="@+id/textView8" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Message to all members"
android:id="@+id/allmessage"
android:layout_alignBottom="@+id/appbutton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/status"
android:id="@+id/status"
android:layout_below="@+id/imageView2"
android:layout_alignLeft="@+id/employee"
android:layout_alignStart="@+id/employee" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="FAMILY"
android:id="@+id/textView8"
android:textColor="#018F99"
android:paddingBottom="15dp"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/emergency"
android:layout_alignStart="@+id/emergency"
android:paddingLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="EMERGENCY"
android:id="@+id/textView2"
android:textColor="#FF0000"
android:layout_below="@+id/emergency"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="LOADSHEDDING\n SCHEDULE"
android:id="@+id/textView10"
android:layout_above="@+id/appbutton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#020202" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/room2"
android:background="@drawable/room2click"
android:layout_alignTop="@+id/emergency"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/gate"
android:background="@drawable/gateclick"
android:layout_below="@+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:layout_alignParentTop="true"
android:layout_toStartOf="@+id/appbutton"
android:background="@drawable/homeautomation1"
android:layout_alignRight="@+id/appbutton"
android:layout_alignEnd="@+id/appbutton"/>
</RelativeLayout>
It's because every device has different resolution and PPI. So basically there are numerous ways in which you can achieve the required task. 1) Use Linear Layout and try "weight". It will divide the screen into various portions and layout won't effect on another device. 2) Use different layout files.(Like earlier we do in eclipse) 3) use different files for values.xml 4) There is a custom library called "sdp" which will the do task automatically for you. Just search over the internet about it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.