Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Spinner dropDownHorizontalOffset not functioning but dropDownVerticleOffest is

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!

like image 502
user3261293 Avatar asked Feb 01 '14 20:02

user3261293


3 Answers

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.

like image 75
user3261293 Avatar answered Oct 22 '22 07:10

user3261293


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.

like image 33
csalazar Avatar answered Oct 22 '22 06:10

csalazar


I think this will work for you:

spinner.setPopupBackgroundDrawable(null);
like image 43
Ali Tariq Avatar answered Oct 22 '22 06:10

Ali Tariq