1.weight attribute Usage
Primarily for view object screen fit ratio
For example, the left side is proportional, the right side is 1:2 proportions
Implementation code:
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:id= "@+id/linearlayout1"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Horizontal"> <LinearLayoutAndroid:layout_width= "0DP"Android:layout_height= "Fill_parent"Android:background= "#ADFF2F"Android:layout_weight= "1"/> <LinearLayoutAndroid:layout_width= "0DP"Android:layout_height= "Fill_parent"Android:background= "#DA70D6"Android:layout_weight= "2"/> </LinearLayout>
Usage: scale horizontally, set the ANDROID:WIDTH=0DP of the view, set the specific scale value of the Android weight property, and so on in the vertical direction.
2.divider attribute usage implement split line
Set up split lines between components, the interface display will be more clear and beautiful, such as
Implementation method:
(1) Adding a View object directly to the layout, displaying a line
< View Android:layout_width = "Match_parent" android:layout_height= "1px" android:background= "#000000" />
(2) using the Divider property to set the split line, you need to prepare the following
- Android:divider setting a picture as a split line
- Android:showdividers setting the position of a split line
- dividerpadding setting the padding of a split line
Android Layout LinearLayout