Issue
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);
The main problem comes with
iv.setImageDrawable(d);
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.
Solution
Use AppCompatImageView which has setImageDrawable() method.
Answered By - Diego Torres Milano
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.