Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the spinner background in Android?

I am developing an app in which I need to change the spinner background layout to match the background color. I researched and found that I need to create a 9 patch image. I have done creating the 9 patch image and used in the app but it looks bigger than the normal spinner and also I couldn't see the drop down button in the spinner as well.

I am so happy if you guys provide me a clear tutorial from start creating the 9 patch image for Spinner and using it in the app.

The spinner looks like

Code for the Spinner

 <Spinner         android:id="@+id/spnIncredientone"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_below="@+id/txtMixtureTitle"          android:layout_marginLeft="5dip"         android:layout_marginRight="5dip"         android:background="@drawable/spinner_background"         android:prompt="@string/selectmixture" /> 
like image 343
vinothp Avatar asked Jun 25 '12 11:06

vinothp


People also ask

What is custom spinner in Android?

Spinner is a widget that is used to select an item from a list of items. When the user tap on a spinner a drop-down menu is visible to the user. In this article, we will learn how to add custom spinner in the app.

What is spinner in Android with example?

Android Spinner is a view similar to the dropdown list which is used to select one option from the list of options. It provides an easy way to select one item from the list of items and it shows a dropdown list of all values when we click on it.


1 Answers

You can set the spinners background color in xml like this:

android:background="YOUR_HEX_COLOR_CODE" 

and if you use the drop down menu with you spinner you can set its background color like this:

android:popupBackground="YOUR_HEX_COLOR_CODE" 
like image 103
Jakob Avatar answered Sep 17 '22 18:09

Jakob