Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Widget.Holo.Spinner-style widget in v7

I have a Button that I want to style like a Holo-style spinner, i.e. underlined with a triangle in the bottom right corner - the built-in contacts app for example does that.

enter image description here

The easiest way is to create the button and style it as style="@android:style/Widget.Holo.Spinner" - that gives me the visual result I want.

However, my app is meant to support Android 2.x, so I can't use native Holo styles. AppCompat has several spinner-related styles, like @style/Widget.AppCompat.Spinner and others, but they don't look the same - they just create a little triangle in the center at the right edge of the widget, and no underline.

I could fudge it by creating my own 9-patch background, but I can't imagine that this Holo spinner style is missing from v7's AppCompat. Is there a style I can use, or any other way to create the visual result I want without creating my own drawable resource?

like image 883
EboMike Avatar asked Nov 14 '14 07:11

EboMike


1 Answers

I wouldn't recommend you to style a button like a spinner. Android have created a particular style for the button for a reason. THe reason behind this simple; you are going to confuse the users of your app if you style a button like a spinner, and they will think that the button is a spinner. That is why the Android design team do not recommend this.

Nonetheless, if you still wish to show the button as a sninner, you can always copy the design of the spinner, save it as an image and set it as the background of yuor button through this xml:

android:background="@drawable/spinner"

The spinner drawable needs to be saved in the drawables folder as an image.

like image 123
Michele La Ferla Avatar answered Oct 14 '22 10:10

Michele La Ferla