I have written a custom compound view with custom attributes. One of the custom attributes is a drawable and the file I wish to use is a Vector Drawable.
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomView, 0, 0)
val iconDrawable = typedArray.getDrawable(R.styleable.CustomView_icon_drawable)
I keep getting a XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
Why is this?
Solved.
I needed to do the following:
val drawableResId = typedArray.getResourceId(R.styleable.CustomView_icon_drawable, -1);
val drawable = AppCompatResources.getDrawable(getContext(), drawableResId)