Objective
Hello everyone, to bring you Android开发工程师文集-layout_weight讲解
an overview, I hope you like
Layout_weight related code Show
<TextView android:layout_width="0dp" android:layout_height="25dp" android:layout_weight="1" android:gravity="center" android:background="#000000"/><TextView android:layout_width="0dp" android:layout_height="25dp" android:layout_weight="2" android:gravity="center" android:background="#f0f0f0"/><TextView android:layout_width="0dp" android:layout_height="25dp" android:layout_weight="3" android:gravity="center" android:background="#a3a3a3"/>
Control occupies a 1:2:3 ratio
android:baselineAligned="false"
This property, which represents not based on the same horizontal plane.
Characteristics
The Layout_weight property in LinearLayout, which assigns the size of the control, and then assigns weight, if the control is set to text information, if the control is the width wrap_content
, then the text information is first sorted and then weight assigned.
If the width is the match_parent
case, the allocation is similar to the above, except that its proportional algorithm is not the same.
weightSum
This can be set to the scale of the entire parent control, android:weightSum="3"
expressed as 3 allocations, then the following layout is divided into 3 points, can be 1:2,2:1 and so on.
Important: The total width minus the width of the setting is allocated.
If you feel good, then you can order a praise!??
Summarize
- This article talks about the Android Development engineer anthology-layout_weight , if you have a better understanding, welcome to communicate
- Positioning: Sharing
Android
& Java
knowledge points, interested to continue to follow
Android Development Engineer Anthology-layout_weight explanation