当我将两个纺纱器放在海绵旁时,我遇到了这个问题。这里是布局的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>
我无法重现您遇到的问题。你是否试过剥离除了两个相邻的spinners之外的所有东西 - 所以只有一个LinearLayout作为root和两个spinners?另外,您是否在Eclipse的预览版中以及实际的设备/仿真器中遇到了这个问题? – 2011-12-29 19:52:03