在android布局中layout_height =“0dip"的效果/含义是什么?

在android布局中layout_height =“0dip

问题描述:

我见过几个使用android:layout_height="0px" 或 "0dip" 但我不明白这有什么影响.这似乎会使布局高 0 像素.是否降低了价值,但还有其他一些因素,例如重量"或任何父视图的高度?

I've seen several examples that use android:layout_height="0px" or "0dip" but i do not understand the impact of this. It seems that would make the layout 0 pixels tall. Is the value mitigated but some other factor like 'weight' or the height of any parent views?

是的,您对权重是正确的,当您希望宽度或高度由权重控制时,其约定将该值设置为 0dip 并让权重控制实际值.虽然我很确定 0 在这里是任意的,但你可以放任何东西,但放 0 会让你的意图更加明确.

Yep you are right about the weight, when you want the width or height to be controlled by weight its convention to set that value to 0dip and let the weight control the actual value. Although I am pretty sure 0 is just arbitrary here you could put anything but putting 0 makes your intention more clear.