Avocarrot / json2view

Update native Android UI on the fly
MIT License
1.51k stars 279 forks source link

VectorDrawable in ImageView #42

Open ishaansrm opened 7 years ago

ishaansrm commented 7 years ago

in ImageView we can normally set app:srcCompat="@drawable/ic_whatever" to set a vectorDrawable, instead of PNGs.

Can we have this support in the lib?

ishaansrm commented 7 years ago

Since internally the lib is using .setImageResource() vector drawable should work, but it isn't on Kitkat and below.

ishaansrm commented 7 years ago

Enabling the flag via AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); makes the vectors work on <=4.4 but this opt-in feature causes memory issues

ishaansrm commented 7 years ago

UPDATE: So this is what I think is happening. setImageResource() works on pre-lollipop because Studio generates PNGs for you. Since these resources are used at runtime, Studio maybe doesnt generate PNGs for them.

I got vectors to work by referencing the ImageView the same way you do for clickable views and then setting the imageView src programatically.