I believe it is impossible from XML right now. I know that Android framework only added support for theme attributes in drawable resources in Lollipop and it doesn't work below API 21. I believe that color resources never got the support.
However, you can do that from code!
final TypedArray attributes = itemView.getContext().obtainStyledAttributes(R.styleable.WowSdkSongViewHolder); try { int colorAccent = attributes.getColor(R.styleable.WowSdkSongViewHolder_colorAccent, 0); final int textColorPrimary = attributes.getColor( R.styleable.WowSdkSongViewHolder_android_textColorPrimary, 0); title.setTextColor(new ColorStateList( new int[][] { ThemeUtils.ACTIVATED_STATE_SET, ThemeUtils.EMPTY_STATE_SET }, new int[] { colorAccent, textColorPrimary })); } finally { attributes.recycle(); }
First you need to get values for attributes in the current theme as you'd normally do. Then you have to create a ColorStateList object. The constructor accepts an array of state lists (actually state arrays, that's way it's int[][]) and an array of corresponding colours. Then you can set this ColorStateList on your TextView with a setTextColor overload.
AppCompat has some handy constants defined in ThemeUtils. However, this class is hidden and in an internal package, so I suggest copying what you need to your own ThemeUtils.