Absrtact: My technical blog is often reproduced by rogue website malicious crawling. Please go to the original: http://www.cnblogs.com/hamhog/p/3907146.html, enjoy neat typography, effective links, correct code indentation, and a better reading experience.
about what the meaning of the android:layout_weight, "the larger the proportion of the Internet" and "the larger the proportion of the smaller" two claims. In fact both of these situations are also available.
Example 1:0DP
<LinearLayoutandroid:orientation= "vertical"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"> <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "0DP"Android:background= "#ff0000"Android:layout_weight= "1"Android:text= "1"/> <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "0DP"Android:background= "#00ff00"Android:layout_weight= "2"Android:text= "2"/></LinearLayout>
Example 2:
<LinearLayoutandroid:orientation= "vertical"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"> <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "Match_parent"Android:background= "#ff0000"Android:layout_weight= "1"Android:text= "1"/> <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "Match_parent"Android:background= "#00ff00"Android:layout_weight= "2"Android:text= "2"/></LinearLayout>
Explanation of the two situations:
The layout first assigns a width to each element, and the remaining space is allocated to each element.
In the allocation width phase, the proportions are based on the reciprocal of Layout_weight, that is, the smaller the more Oita.
In allocating the remaining space phase, the proportions are in accordance with layout_weight, that is, the greater the larger the Oita.
In case one, the fixed width is 0, only the second stage; In case two, the allocation width can fill all the space, only the first stage.
So if you want to strictly let it in a certain proportion, you can try to set it to 0DP. At this point the proportions of each element are weight.