Android button with different background colors

前端 未结 4 848
借酒劲吻你
借酒劲吻你 2020-12-07 15:34

i want to change the background-color of a button using a selector-xml-file. My approach is basically the one from the example at the bottom this page: http://developer.andr

4条回答
  •  情歌与酒
    2020-12-07 16:21

    In the URL you pointed to, the button_text.xml is being used to set the textColor attribute.That it is reason they had the button_text.xml in res/color folder and therefore they used @color/button_text.xml

    But you are trying to use it for background attribute. The background attribute looks for something in res/drawable folder.

    check this i got this selector custom button from the internet.I dont have the link.but i thank the poster for this.It helped me.have this in the drawable folder

    
    
        
            
                
                
                
                
            
        
    
        
            
                
                
                
                
            
        
    
                
            
                
                
                
                
            
        
    
    
    

    And i used in my main.xml layout like this

    Hope this helps. Vik is correct.

    EDIT : Here is the colors.xml

    
    
       #F9E60E
       #F9F89D
       #F7BE45
       #F7D896
       #19FCDA
       #D9F7F2
       #ACA899
       #FFFFFF
       #DDDDDD
    
    

提交回复
热议问题