Android中将layout_width或layout_height设置为0的情况

当使用view的layout_weight属性时,可以将layout_width设置为0,原因是这样可以让系统减少一次长度或宽度的计算。


官方解释如下:

In order to improve the layout efficiency when you specify the weight, you should change the width of theEditText to be zero (0dp). Setting the width to zero improves layout performance because using"wrap_content" as the width requires the system to calculate a width that is ultimately irrelevant because the weight value requires another width calculation to fill the remaining space.


示例:

    


你可能感兴趣的:(Android之UI篇)