选项1:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp" />
</RelativeLayout>
选项2:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible" />
</LinearLayout>
可以有很多其他解决方法。
编辑
正如您在您的评论澄清,看到this answer
几乎就是我要找的。应该提到我希望它遵循所选项目的长度。因为所选的项目可能是5个字符或15个字符。我希望选择器图标始终位于旁边。你的选择给它一个静态位置。但我非常期待这一步! – Serellyn 2015-02-09 12:50:44
看到我的编辑结束(去http://stackoverflow.com/a/13967767/1039555) – 2015-02-09 22:18:38
谢谢你的帮助:) – Serellyn 2015-02-10 11:08:23