在的LinearLayout元素的宽度成正比 [英] Proportional width of elements in LinearLayout
问题描述
我有一个水平的LinearLayout
,并在其中我有的EditText
和微调
元素。
哪些属性我需要调整,所以我会得到正比宽度:我想的EditText
取3/5和微调
- 所有可用宽度的2/5?
I have a horizontal LinearLayout
and in it I have EditText
and Spinner
elements.
Which attributes I need to adjust so I would get proportional widths: I want EditText
to take 3/5 and Spinner
- 2/5 of all available width?
我的code是这样的:
My code looks like this:
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/LinearLayout01">
<EditText
android:layout_height="wrap_content"
android:id="@+id/EditText01"
android:singleLine="true">
</EditText>
<Spinner
android:layout_height="wrap_content"
android:id="@+id/Spinner01"
android:layout_width="wrap_content">
</Spinner>
</LinearLayout>
我试过设置的android:layout_weight
,但不知何故,它看起来并不稳定足以让我 - 当的EditText
有没有文字 - 一切看起来不错,但只要我开始输入文本 - 它开始扩大和微调
相应萎缩...
I tried setting android:layout_weight
, but somehow it does not look "stable" enough for me - when EditText
has no text - everything looks fine, but as soon as I start entering text into it - it starts expanding and Spinner
shrinking accordingly...
推荐答案
要逐字地达到你的要求,尝试设置两个小部件的android:layout_width =0像素
,然后设置你的的android:layout_weight
适当的值( 3
和 2
)。
To literally achieve your request, try setting both widgets' android:layout_width="0px"
, then set your android:layout_weight
values as appropriate (3
and 2
).
这篇关于在的LinearLayout元素的宽度成正比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!