Phil Wright Phil Wright - 2 months ago 16
Android Question

Crash when inflating a layout that sets the TextView.TextColor

I cannot inflate a layout if that layout sets the textColor of a TextView to the following...

android:textColor="?android:attr/textColor"


I believe that the value is definitely defined for the application because I have a drawable that also references this resource and it works just fine. But if I try and use the accent color instead then it will work fine, e.g.

android:textColor="?android:attr/colorAccent"


What is different about the textColor value?

Answer Source

I would have to assume you are looking for the primary text color of your theme, thus you would use:

android:textColor="?android:attr/textColorPrimary"

There are a dozen or so textColorXXXX attributes, so you would need to review them to see which one you are actually trying to use.