I recently added different themes to my app and therefore need to have icons tinted differently for each theme.
<ImageView
...
android:src="@drawable/ic_info"
android:tint="?colorControlNormal"
But on API levels below 21 this does not work. I'm using vectordrawables and already tried to use
vectorDrawables.useSupportLibrary = true
and
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
but that didn't help either.
The tinting support documentation is quite ambiguous and with the combination of using VectorDrawables and referencing a theme color, I couldn't find any information.
currently trying to use:
<android.support.v7.widget.AppCompatImageView
...
android:tint="?colorControlNormal"
android:src="@drawable/icon"/>
which results in:
Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class android.support.v7.widget.AppCompatImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:621)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
...
Caused by: java.lang.NumberFormatException: Invalid int: "res/color/abc_secondary_text_material_light.xml"
at java.lang.Integer.invalidInt(Integer.java:137)
at java.lang.Integer.parse(Integer.java:374)
at java.lang.Integer.parseInt(Integer.java:365)
at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:122)
at android.content.res.TypedArray.getInt(TypedArray.java:255)
at android.widget.ImageView.<init>(ImageView.java:155)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)