Graphic of relative layout and graphic of adaptive screen
In multiple ways to adapt to multiple screens, the relative layout is more common, while the alignment is commonly used in the relative layout:
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <RelativeLayout android: layout_width = "match_parent" android: layout_height = "0dp" android: layout_weight = "1" android: gravity = "center"> <TextView android: id = "@ + id/left1" android: layout_width = "100dp" android: layout_height = "50dp" android: background = "# FF4500" android: gravity = "center" android: text = "Left" android: textSize = "10pt"/> <TextView android: id = "@ + id/right1" android: layout_width = "80dp" android: layout_height = "wrap_content" android: background = "#00CD00" android: gravity = "center" android: text = "right" android: textSize = "10pt"/> </RelativeLayout> <RelativeLayout android: layout_width = "match_parent" android: layout_height = "0dp" android: layout_weight = "1" android: gravity = "center"> <TextView android: id = "@ + id/left2" android: layout_width = "100dp" android: layout_height = "50dp" android: background = "# FF4500" android: gravity = "center" android: text = "Left" android: textSize = "10pt"/> <TextView android: id = "@ + id/right2" android: layout_width = "80dp" android: layout_height = "wrap_content" android: layout_alignRight = "@ id/left2" android: background = "#00CD00" android: gravity = "center" android: text = "right" android: textSize = "10pt"/> </RelativeLayout> <RelativeLayout android: layout_width = "match_parent" android: layout_height = "0dp" android: layout_weight = "1" android: gravity = "center"> <TextView android: id = "@ + id/left3" android: layout_width = "100dp" android: layout_height = "50dp" android: background = "# FF4500" android: gravity = "center" android: text = "Left" android: textSize = "10pt"/> <TextView android: id = "@ + id/right3" android: layout_width = "80dp" android: layout_height = "wrap_content" android: layout_toRightOf = "@ id/left3" android: background = "#00CD00" android: gravity = "center" android: text = "right" android: textSize = "10pt"/> </RelativeLayout> <RelativeLayout android: layout_width = "match_parent" android: layout_height = "0dp" android: layout_weight = "1" android: gravity = "center"> <TextView android: id = "@ + id/left4" android: layout_width = "100dp" android: layout_height = "50dp" android: background = "# FF4500" android: gravity = "center" android: text = "Left" android: textSize = "10pt"/> <TextView android: id = "@ + id/right4" android: layout_width = "80dp" android: layout_height = "wrap_content" android: layout_alignBottom = "@ id/left4" android: layout_toRightOf = "@ id/left4" android: background = "#00CD00" android: gravity = "center" android: text = "right" android: textSize = "10pt"/> </RelativeLayout> <RelativeLayout android: layout_width = "match_parent" android: layout_height = "0dp" android: layout_weight = "1" android: gravity = "center"> <TextView android: id = "@ + id/left5" android: layout_width = "100dp" android: layout_height = "50dp" android: background = "# FF4500" android: gravity = "center" android: text = "Left" android: textSize = "10pt"/> <TextView android: id = "@ + id/right5" android: layout_width = "80dp" android: layout_height = "wrap_content" android: layout_alignBaseline = "@ id/left5" android: layout_toRightOf = "@ id/left5" android: background = "#00CD00" android: gravity = "center" android: text = "right" android: textSize = "10pt"/> </RelativeLayout> </LinearLayout>
How can the layout of the android development interface be adapted to the full model?
Use relative layout, do not use absolute coordinates, do not use relatively large fixed size image resources
Android uses a relatively layout. If there are four buttons in a row, how can we make the four buttons as big and full of the screen width?
In this case, we should use linearity and set their weights to the same value. In addition, we need to flexibly use nested values.