選項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