Anthea
Anthea

Reputation: 3809

Change the appearance of a Spinner in Android

I want to change the appearance of a spinner so that it looks like a textview at the outside. My current approach is this:

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

and the style resources:

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

It does not throw any error but also has no effect on the appearance. Alternativly I might bind a spinner on a Textview, but don't know how :)

Thanks for any help.

Upvotes: 0

Views: 3775

Answers (2)

frayab
frayab

Reputation: 2512

You have to set background to null:

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

Upvotes: 0

Gophermofur
Gophermofur

Reputation: 2101

I believe you need to change the background of the spinner as that's what gives it the 'spinner' look (textarea + arrow).

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

It would be best to use a 9-Patch drawing to replace the background so you can represent any text properly.

Upvotes: 1

Related Questions