Adding an Icon on a Spinner on Android

Hannah Olukoye
2 min readAug 2, 2017

Since I started using spinners I keep discovering how many constraints exist in this widget. At first, it was the fact that the text size/type is a challenge to customize and recently the discovery I discovered how to add an icon to the Spinner widget.

It’s quite simple to add a drawable to a TextView Widget or an EditText Widget but for a Spinner it’s not as straightforward as this.

I know someone might have struggled like me, so here are the steps I used to accomplish this.

Step 1. Create an array and a desired background “image.xml” file.

spinner_rect.xml

Step 2. Add the spinner widget in your layout file as follows.

Step 3. Create a layout file with the desired icon as follows.

--

--

Hannah Olukoye
Hannah Olukoye

Written by Hannah Olukoye

Google Developer Expert— Android Engineering Manager

Responses (5)