2015-02-08 110 views
0

我想知道是否(以及如何)可以更改微調器選擇器圖標的圖標位置。在這一點上,我已經讓我的微調器的寬度匹配父(全屏),然後得到文本居中。所以在這一刻,文本居中,但選擇器圖標在最右邊...Android微調,選擇器圖標位置

我真正想要的是所選項目旁邊的圖標。我已經添加了一張圖片以供澄清。

enter image description here

預先感謝您。

編輯:我希望選擇器圖標始終位於所選項目的旁邊,選定的項目可以是5到15個字符的變量。所以,它的位置不應該是靜態的,而是動態的跟隨微調的所選項目...

回答

1

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

+0

幾乎就是我要找的。應該提到我希望它遵循所選項目的長度。因爲所選的項目可能是5個字符或15個字符。我希望選擇器圖標始終位於旁邊。你的選擇給它一個靜態位置。但我非常期待這一步! – Serellyn 2015-02-09 12:50:44

+0

看到我的編輯結束(去http://stackoverflow.com/a/13967767/1039555) – 2015-02-09 22:18:38

+0

謝謝你的幫助:) – Serellyn 2015-02-10 11:08:23