Android: Need to change the spinner background color

后端 未结 2 573
南方客
南方客 2021-01-03 09:03

I\'m using three spinners inside of my XML file. Want to change spinner color until press the next spinner.

This is my xml I used:



        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 09:25

    Inspired by Gustavo's answer, here is my version of Spinner's background with DropDown arrow. Just the complete background, not only the arrow.

    This is how it looks

    Apply on spinner like

    
    

    spinner_bg.xml

    
    
    
    
    
    
    
    
    
        
            
            
        
    
    
    
    
        
    
    
    
    
    
    

    @color/InputBg should be replaced by the color you want as your background.

    First it fills the background with desired color. Then a child layer-list makes a square and rotates it by 45 degrees and then a second Rectangle with background color covers the top part of rotated square making it look like a down arrow. (There is an extra stroke in rotated rectangle with is not really required)

提交回复
热议问题