use setBackgroundResource or setBackgroundColor . I think at first itโs pretty simple.
The second takes int as an argument. So, just convert your hexagonal color (e.g. #55000000 ) to decimal, and it will work as well.
However, it is better to use setBackgroundResource , because in this case you save your colors in a separate file:
setBackgroundResource(R.color.mycolor); setBackgroundResource(android.R.color.transparent);
source share