2015-07-20 33 views
0

有在colors.xml颜色不透明度。我知道我可以为colors.xml添加透明度,如#CC666666。但我需要以编程方式添加此透明度。增加透明度以编程方式使用的是Android颜色资源

colors.xml

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

int color = getResources().getColor(R.color.list_section); 
// put transparency here 
myView.setBackgroundColor(color); 

回答

3

猜位或可以工作。 喜欢的东西

int transparentColor = 0xCC000000 | color; 
myView.setBackgroundColor(transparentColor);