问题
I made a color resource, but I was wondering how to make it slightly transparent. I'm using it for an image button background. I'm trying to make it highlight like it automatically does when you have the default background. I've looked up some stuff but I just can't seem to find what I'm looking for, so I decided to ask on here.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
</resources>
That's literally all I have for the colour resource right now, but I want to make that transparent.
回答1:
On Android, colors have four bytes. The first byte of the value is the alpha channel, then the red, green, and blue components. If you don't specify the alpha channel, it defaults to FF (opaque).
If you want to make a partially transparent color, simply specify an alpha channel.
<color name="white">#CCFFFFFF</color>
来源:https://stackoverflow.com/questions/17768453/how-to-create-a-transparent-color-resource