2

I want to dim the background around a spinner dropdown, but I cannot find any way to accomplish this.

Research has uncovered the possibility of placing a fullsize framelayout between the activity and the spinner dropdown, and setting a background colour and alpha value on this.

However, I cannot find anyway to determine when the actual dropdown is getting displayed so that I can insert this frame.

Am I looking at this problem the wrong way? Surely there must be a way to dim the background behind a spinner dropdown.

JymmyZ
  • 126
  • 8
  • I do not think, putting a framelayout is a good way to solve this issue. Your question is a possible duplicate to : http://stackoverflow.com/questions/11188398/how-to-change-the-spinner-background-design-and-color-for-android – user3793589 May 22 '15 at 16:02
  • It's quite likely that it might not be the best way to solve this issue, but it's the closest thing I've found to an answer so far. I'm not trying to change the background of the dropdown itself. I need to "dim" the background around the actual dropdown, basically, gray out the underlying activity while the spinner dropdown is open. – JymmyZ May 22 '15 at 16:05
  • For reference, this is the only thing resembling an answer I've been able to find http://stackoverflow.com/questions/23405177/android-spinner-dim-background – JymmyZ May 22 '15 at 16:07
  • mhm interesting... You might wanna check this clue of customization then... http://mrbool.com/how-to-customize-spinner-in-android/28286 – user3793589 May 22 '15 at 16:14
  • Thanks, but unfortunately it doesn't help solve my problem either. All it does is allow for creating custom listview items in the dropdown. – JymmyZ May 22 '15 at 19:10
  • I'm facing the same problem, JymmyZ, did you find the solution? – Mike Oct 29 '18 at 14:35

2 Answers2

0

I think you should be able to use the Spinner.OnClickListener. When this is called, you can dim the screen with your framelayout

tim687
  • 2,256
  • 2
  • 17
  • 28
  • Spinners do not allow onClick listeners. That just crashes the app – JymmyZ May 22 '15 at 16:05
  • Which OnClickListener did you use? Try to use View.OnClickListener for this and if that doesn't work try DialogInterface.OnClickListener – tim687 May 23 '15 at 08:36
  • Can you post some code? That way we can also figure out the best solution – tim687 May 26 '15 at 12:44
0

I ended up using something very similar to this answer in a related question. https://stackoverflow.com/a/18636385

Along with a RelativeLayout in the activity to act as a dimming mask.

Community
  • 1
  • 1
JymmyZ
  • 126
  • 8