Android: Using selector to set background color for image view

后端 未结 5 998
情歌与酒
情歌与酒 2020-12-15 22:45

I am trying to set the background color of an image view.

 

        
5条回答
  •  庸人自扰
    2020-12-15 23:36

    The simplest way to do what you want is adding a child node to the item instead of using its drawable attribute:

    
    
        
            
        
        
            
        
        
            
        
    
    

    Here you can use direct values for color as well (e.g. #FFFF0000 instead of "@color/red") to save yourself from defining many color resources.

提交回复
热议问题