Michał Z.
Michał Z.

Reputation: 4119

Incorrectly stretched VectorDrawableCompat when nested in DrawableContainer

My usecase was to create a splash screen (don't ask, I just had to).

I've found this excellent post by Ian Lake: https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd and tried to do this but using VectorDrawableCompat.

So instead of a <bitmap> I've put:

<item
    android:drawable="@drawable/vector_logo"
    android:gravity="center"/>

Of course I turned on AppCompatDelegate.setCompatVectorFromSourcesEnabled(true);

It looks nice on L and above but for pre-L where support vectors are used my icon is stretched to fill entire screen. I've tried to set width and height attributes on item tag but it seems that it has no effect at all. Can I do anything about it? I would like to use a vector asset.

Upvotes: 3

Views: 378

Answers (1)

I had the same problem and I believe we will not have a solution soon, I already tried a lot of things like set item drawable with hardcoded width and height or with other tags inside and with app:srcCompat and nothing did the trick :/

Others with similar issues like https://code.google.com/p/android/issues/detail?id=196030 received the response: "As the issue is not there in Marshmallow builds, we would request you to use latest API level, since our eng teams are not prioritizing changes on earlier releases" and nothing more.

Unfortunately, to solve my problem I had to duplicate the drawable, converting my vector to a .png to use with < bitmap> like the Ian Lake post.

Upvotes: 2

Related Questions