Question

I want to set my android linkify text color to a custom color however mText.setLinkTextColor("#2f6699"); does not work, I have been searching for a built in method that will compile a hexidecimal value but I havent found one, any help will go a long way thanks

Was it helpful?

Solution

You should convert it to a Color. Try:

mText.setLinkTextColor(Color.parseColor("#2f6699"));

OTHER TIPS

You can use also android:textColorLink="#2f6699" in xml.

Try something like this:

noteView.setLinkTextColor(Color.green);

If you want to set an hexadecimal color:

noteView.setLinkTextColor(Color.argb(int alpha, int red, int green, int blue));

Replacing alpha/red/green/blue with the desired values. The documentation on the Color class can be found here

As resources.getColor() function deprecated we can try this alternative way.

textView.setLinkTextColor(ContextCompat.getColor(this,R.color.colorBlue))

Thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top