Compact spinner widgets

My application uses a couple of spinner widgets. With limited screen space, they just seemed too large. I tried various ways to make them smaller, like setting padding and layout margins to small values, including zero, but that didn’t help. The empty space around the spinner stayed there no matter what, I was just unable to make it go away.

Then I had the idea to try and change the background. This turned out to be what was needed – it’s the background that defines a spinner’s size, and what looked like margins was just empty pixels in the background image.

So here are my background .png files:

Use them like this:

Create an xml file describing normal and pressed states for the background

This is a screenshot showing my “slim” spinners side-by-side with the regular ones (HTC Hero):

My slim spinners vs. stock ones

BTW: Digging through Android 1.5 sources, I found a .9.png file that is apparently the stock spinner background. It seems even larger than those shown above. So apparently, HTC had the same idea when tweaking Android for the Hero… they just didn’t go as far.