How to create a transparent Color Resource?

扶醉桌前 提交于 2020-01-16 02:42:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!