Skip to content Skip to sidebar Skip to footer

Android:textcolor No Longer Works In Marshmallow

I have written an app which relies on colors defined in resources. Some are set directly in the layout XML file, others are set in code. Examples: Color definition in res/values/st

Solution 1:

Use ContextCompat class, It is helper class for accessing features in Context introduced after API level 4 in a backwards compatible fashion.

accStatus.setTextColor(ContextCompat.getColor(context, R.color.somecolor));

public static final int getColor (Context context, int id)      Returns a color associated with a particular resource ID

Solution 2:

Got it.

Wherever I had this issue, the text displayed in the control was a single square (U+2b1b). When I alter this text (e.g. by appending an X), only the square will display in orange and the rest of the string has the desired color.

Changing it to a small square (U+25fc) fixed things. Some other special characters would give me other colors – apparently certain characters are fixed to certain colors on Marshmallow, when on earlier versions they could be styled like any other text.

Solution 3:

Faced the same problem on my Sony Xperia (Android 6.0 Marshmallow). The reason was that the Settings/Accessibility/High contrast text (experimental) was enabled.

When I disabled it, it worked fine again as expected.

Post a Comment for "Android:textcolor No Longer Works In Marshmallow"