關於layout_weight屬性,以layout_width爲例:
當layout_width爲fill_parent時,對於一個組件,該組件相對於其它組件的layout_weight值越小時,它的寬度相對於其它組件越大。但最大不超過fill_parent。
當layout_width爲wrap_content時,對於一個組件,該組件相對於其它組件的layout_weight值越小時,它的寬度相對於其它組件越小。但最小不小於wrap_content。
layout_height類似。
android官方文檔:
layout_weight
is used in LinearLayouts to assign "importance" to Views within the layout. All Views have a default layout_weight
of zero, meaning they take up only as much room on the screen as they need to be displayed. Assigning a value higher than zero will split up the rest of the available space in the parent View, according to the value of each View's layout_weight
and its ratio to the overalllayout_weight
specified in the current layout for this and other View elements.