开发者

layout_weight to give one item exactly as much space as it needs, and all remaining to the other item

I'm trying to render an EditText password field followed by a Checkbox whose text is "show?". Both are in a horizontally-oriented LinearLayout.

I want the check开发者_如何学编程box and its label to occupy exactly as much space as they need to render without squishing, wrapping, or mangling -- no more, no less -- and give the remainder of the row's width to the EditText.

Is there some semi-magic layout_weight value that literally means (on its own, or in combination with one or more other attributes) "give this element exactly as much width as it needs to render normally without squishing, wrapping, or manging -- but no more?" And another that means "give this element all available space that remains after satisfying everything else first"?


All you need to do is set android:layout_width="wrap_content” on both controls and set android:layout_weight="1" on the EditText.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜