Is there a way to set drawable's Alpha using XML?

后端 未结 9 915
无人及你
无人及你 2020-12-24 05:21

Easy like itself . I wanna make an alpha button , which would have a selected drawable this way:




        
9条回答
  •  感动是毒
    2020-12-24 05:24

    It's been a while since the OP, but personally found a solution that worked a lot better for me than the suggested answers. Creating a BitmapDrawable makes is easily possible to set the alpha:

    
    
    
    

    Alpha can be any value between 0 and 255. Note that it is sort of the inverse of the HEX color value alpha, as for example 70% alpha would be B3 in HEX and 77 in the BitmapDrawable.

提交回复
热议问题