0

There is a color in colors.xml without transparency. I do know that i can add transparency to colors.xml like #CC666666. But i need to add this transparency programatically.

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="list_section">#666666</color>
</resource>

in my Activity:

int color = getResources().getColor(R.color.list_section);
// put transparency here
myView.setBackgroundColor(color);
heloisasim
  • 4,956
  • 2
  • 27
  • 36

1 Answers1

4

Guess bitwise OR could work. Something like

int transparentColor = 0xCC000000 | color;
myView.setBackgroundColor(transparentColor);
fedepaol
  • 6,834
  • 3
  • 27
  • 34