Android layout_weight案例分析总结

关于layout_weight,我们一般就理解为布局权重的意思,Android官方的说明如下:
Formats: float
Indicates how much of the extra space in the LinearLayout is allocated to the view associated with these LayoutParams. Specify 0 if the view should not be stretched. Otherwise the extra pixels will be pro-rated among all views whose weight is greater than 0.

可赋值类型为float,
layout_weight的含义是:在线性布局中,这些控件各自占据的空白区域的比重。
为0,表示该控件不会被拉伸以适应布局;其他值则表示,控件在布局空白区域中的占地比例。

结合实际例子来看看:
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"

猜你喜欢

转载自blog.csdn.net/poolooloo/article/details/106921543