【发布时间】:2012-01-30 02:43:14
【问题描述】:
当我将两个微调器放在一起时,我遇到了这个问题。这是布局xml的片段:
...
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<Spinner
android:id="@+id/x"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_weight="1" />
<Spinner
android:id="@+id/y"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_weight="1" />
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
<ListView
android:id="@+id/z"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#FFFFFF" >
</ListView>
...
...
结果如下:
我尝试了很多不同的东西。我试过改变权重、重力、改变父类为RelativeLayout,但结果还是一样。
请帮忙!
编辑:
好的。我得到了它。一些冗余,但它解决了问题。有点奇怪,为什么这行得通,而“正常方式”却行不通。谢谢大家的帮助。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<Spinner
android:id="@+id/x"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1" >
<Spinner
android:id="@+id/y"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
</RelativeLayout>
</LinearLayout>
【问题讨论】:
-
我无法重现您遇到的问题。您是否尝试过剥离除彼此相邻的两个微调器之外的所有内容 - 所以只有一个 LinearLayout 作为根和两个微调器?另外,您在 Eclipse 的预览版以及实际的设备/模拟器中是否有此问题?
标签: android android-layout spinner android-spinner