weightSum and layout_weight and why 0dp is sometimes set

The weightSum of linear layout (horizontal as an example) defines the maximum weight of the sub-control. If not specified, it is equal to the cumulative sum of layout_weight of all sub-views.

The layout_weight of the subview occupies the proportion of space of the parent view.


Calculation of the true width of a linear layout's subviews:

 The width of the subview itself + its own proportion/total proportion * the width of the parent view


Why does the development environment suggest changing width="wrap_content" to 0dp after setting layout_weigth? This eliminates the need to calculate its own width and improves efficiency.


http://book.51cto.com/art/201404/435840.htm

Guess you like

Origin blog.csdn.net/konga/article/details/46955915