I want to create a drop-down color set, something like this (sorry for the ugly image):

I only need some colors (say 6), so I donβt need a full set of colors, the drop-down menu will work fine.
I know that I need to expand the array adapter for Spinner and override getDropDownView and getView .
I do not know how to create a square frame with a border and a solid background color.
I know that I can define my own form inside drawable. In any case, I need to set the background color at runtime, so I also need to change the view and set the correct background color.
What is the best way to do this? Thanks.
source share