以编程方式设置可绘制的矢量棒棒糖之前
问题描述:
一个非常常见的问题,我无法解决.我正在以编程方式设置向量.我也希望能够以编程方式更改色调颜色.找到了一些解决方案,例如以编程方式为支持向量着色
Very common problem with a twist to which I couldn't find a solution for. I am setting my vector programmatically. I want to be able to change the tint color programmatically too. Found some solutions such as Programmatically tint a Support Vector
ImageView iv = ....
Drawable d = VectorDrawableCompat.create(getResources(), R.drawable.ic_exit_to_app_24dp, null);
d = DrawableCompat.wrap(d);
DrawableCompat.setTint(d, headerTitleColor);
iv.setImageDrawable(d);
主要问题来自
iv.setImageDrawable(d);
我发现prelolipop仅接受设置视图的可绘制对象,
I found that prelolipop only accepts setting view's drawable with
iv.setImageResource(int resource)
我找不到用可绘制文件设置它的任何解决方案.
I couldn't find any solutions for setting it with a drawable file.