2012-05-18 62 views
0

我想更改微調框的外觀,使其看起來像外部的文本視圖。我目前的做法是這樣的:在Android中更改微調框的外觀

<Spinner 
    android:id="@+id/spinner" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    style="@style/spinner_style"/> 

和作風資源:

<style name="spinner_style" parent ="@android:attr/textViewStyle"> 
    <item name="android:layout_width">wrap_content</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:textAppearance">@style/MyText</item> 

</style> 


<style name="MyText" parent="@android:style/TextAppearance"> 
    <item name="android:textColor">#00ffff</item> 
</style> 

它不會引發任何錯誤,但也有對外觀沒有影響。另外我可能會綁定一個微調的Textview,但不知道如何:)

感謝您的任何幫助。

回答

1

我相信你需要改變微調器的背景,因爲這就是它的'微調'外觀(textarea +箭頭)。

<item name="android:background">@android:color/transparent</item> 

最好使用9-Patch圖來替換背景,以便可以正確表示任何文本。

+0

我試圖設置<項目名稱=「機器人:背景」> @色/紅色和它的工作很大。最好的辦法是將其設置爲null以便沒有背景。我將如何在XML中執行此操作? – Anthea

+0

我很困惑。如果您嘗試將背景設置爲紅色並且它可以正常工作,那麼您爲什麼不保持這種方式呢?你的評論*是*使用XML,你只是使用樣式來實現你所需要的,這是一件好事。 – Gophermofur

+0

我不想讓背景變成紅色,我希望它像普通的textview一樣隱形。 @ color/null不能工作,因爲null是未知的... – Anthea

0

你必須設置背景爲null:

<item name="android:background">@null</item>