Why isn’t my vector drawable scaling as expected?

There is new info about this issue here:

https://code.google.com/p/android/issues/detail?id=202019

It looks like using
android:scaleType="fitXY" will make it scale correctly on Lollipop.

From a Google engineer:

Hi, Let me know if scaleType=”fitXY” can be a workaround for you , in
order to get the image look sharp.

The marshmallow Vs Lollipop is due to a special scaling treatment
added into marshmallow.

Also, for your comments: ” Correct behavior: The vector drawable
should scale without quality loss. So if we want to use the same asset
in 3 different sizes in our application, we don’t have to duplicate
vector_drawable.xml 3 times with different hardcoded sizes. ”

Even though I totally agree this should be the case, in reality, the
Android platform has performance concern such that we have not reach
the ideal world yet. So it is actually recommended to use 3 different
vector_drawable.xml for better performance if you are sure you want
to draw 3 different size on the screen at the same time.

The technical detail is basically we are using a bitmap under the hook
to cache the complex path rendering, such that we can get the best
redrawing performance, on a par with redrawing a bitmap drawable.

Leave a Comment