Aug 31, 2018 · 1 min read
My TextView is throwing an UnsupportedOperationException when I use ?attr/primaryColor1 for color
attrs.xml
<resources>
...
<attr name="primaryColor1" format="reference" />
</resources>styles.xml
<style name="AppThemeGreen" parent="Theme.AppCompat.Light">
...
<item name="primaryColor1">@color/weird_green</item>
</style>androidManifest.xml
<application
...
android:theme="@style/AppThemeGreen">TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/this_week"
android:textColor="?attr/primaryColor1" />