I have been diving into the world of Android Spinner controls recently and ran into a small issue. I need to align the left side of the drop down with the very far left of the main spinner control. I have tried using dropDownHorizontalOffset to align them and no matter what value I use the horizontal position of the drop down doesn't change, but when I test with dropDownVerticleOffset the vertical position of the drop down does change.
Has anyone worked with those values or might have any idea of how else I could go about aligning them?
Thanks!
Solved: I tried the suggested padding change instead of dropDownHorizontalOffset and it did work, the problem was that it also changed the position of the text in the primary spinner object which made it look not so great. So that method does work but is not preferable.
The problem was that we were using a pre 4.1 overall theme for our application (theme.NoTitleBar) and dropDownHorizontalOffset was not supported with that old of a theme because spinners in general were not fully supported then. I changed it to Theme.Holo.Light.NoTitleBar and everything worked fine! I don't think this is too common of an issue but hopefully it can help someone.
I accomplished the same objective by removing the background of the popup.
spinner.setPopupBackgroundDrawable(null);
That code will remove the background, (and the padding that's coming with it), and therefore will position your dropdown aligned with the spinner.
Obviously, you will need to use your own drawable instead if you don't want it to be transparent.
I think this will work for you:
spinner.setPopupBackgroundDrawable(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With