关于android的layout_weight属性

 

关于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.

你可能感兴趣的:(android,UI,width,weight)