BackgroundColorSpan is always yellow

1.5k Views Asked by At
textToSpan.setSpan(new BackgroundColorSpan(0xBFFFC600), o, o + termLength, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

for some reason the color is always yellow. I have tried two greenish colors :

0xBFFFC6 and 0x99FF99

I sense I am messing up somewhere with the order of the colors.

2

There are 2 best solutions below

1
On BEST ANSWER

The actual solution was to get the color like so:

getResources().getColor(R.color.LightGreen)

I still do not know why it has to be like this.

0
On

You need to parse the color before giving it to BackgroundColorSpan:

new BackgroundColorSpan(Color.parseColor("#BFFFC6"))