Sunday, December 26, 2010

In-correct arrow icon on Spinner with custom ArrayAdapter

Refer to the exercise "Custom ArrayAdapter for Spinner, with different icons"; it implement a Spinner with custom ArrayAdapter, base on Build Target of Android 1.6, and android:minSdkVersion="4".

When it run on AVD of Android 2.1, the drop-down arrow on the right side is in-corret.
Run on AVD of Android 2.1

The same code, when it run on AVD of Android 2.3, the arrow is displayed correctly.
Run on AVD of Android 2.3

Up to this minute, I have no any idea on this problem. Sorry for any inconvenience caused!

Updated@2012-01-13: Please read command by RSZ below.

3 comments:

I Me Myself said...

Thank you for your very useful post... I realised that it was the arrow getting distorted becoz of the image icon, so on further searching, I found tihs...am posting it here to help others...

http://androidforbeginners.blogspot.com/2010/10/spinner-down-arrow-stretching.html

none said...

for everybody having this problem: its not - depending of what you want to do - necessarily a problem caused by a wrong style.

remember: spinner has a hight layout of "wrap_content" and if you place a image bigger than the default spinner size (or, like in the example above a text bigger then the default spinner size) the spinner will expand in hight. since the spinner always gives you the space your items need, there is no way to stop expanding. if the image is 500 px high the spinner will be too. if you try using stuff like scaleType or wrap_content for the image view it will not work since the parent don't make ANY size restrictions. the only change to change this is to define a fixed size in dp for the image hight OR the fixed hight for the spinner itself (so the child image now has a boundary to scale to)

Erik said...

hello RSZ,

Thanks for your advise.