Android Layout - layoutweight and weightsum

前端 未结 2 730
攒了一身酷
攒了一身酷 2020-12-03 11:53

I need to build a layout with the set of linear layouts. The layout has to occupy a defined percentage of the screen. I need to do this to have a similar look in all the dev

2条回答
  •  旧时难觅i
    2020-12-03 12:08

    Start your layout_width or layout_height as 0dp instead of wrap_content. (If it's in a vertical layout, layout_height should be 0dp; if it's in a horizontal layout, layout_width should be 0dp)

    The layout_weight describes how to divide the remaining space after the layout_widths/layout_heights have been assigned.

    Note that wrap_content doesn't mean "make the text wrap"; it means set that dimension to the "preferred" dimension of the view.

提交回复
热议问题