Android button with different background colors

前端 未结 4 846
借酒劲吻你
借酒劲吻你 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:17

    As your error states, you have to define drawable attibute for the items (for some reason it is required when it comes to background definitions), so:

    
    
         
         
         
    
    

    Also note that drawable attribute doesn't accept raw color values, so you have to define the colors as resources. Create colors.xml file at res/values folder:

    
    
         #000
         #00f
         #f00
    
    

提交回复
热议问题