Vector image displaying wrong in Android
Asked Answered
R

5

7

When I go to import a vector image using Android Vector Asset Studio, it becomes distorted, even in the preview. One of the vectors I was attempting to use was the photo outline straight from the Material site.

Here is what it is supposed to look like: enter image description here

This is what it looks like in Android: enter image description here

Here is one other example with what it's supposed to look like and then how it looks in Android: enter image description here enter image description here

If you want any other info let me know. Any help would be greatly appreciated.

Reform answered 21/3, 2019 at 1:48 Comment(2)
It seems that your vector drawable was damaged. How about remove it and download original image again?Alarcon
@StanleyKou I did try that but no luck. I did open both the svgs in Inkscape and they looked correct.Reform
T
3

use <androidx.appcompat.widget.AppCompatImageView instead of ImageView and also use app:srcCompat insted of android:src=

Tegantegmen answered 21/8, 2021 at 5:24 Comment(1)
I was having this issue only on Amazon Fire OS 5 (Android 5.1 SDK 22) devices and this fixed it for me. Thanks!Autrey
H
0

The same thing happened when I imported a local file in Asset Studio. The imported image is below.

photo image

However, it was displayed correctly when selecting from Clip Art in Asset Studio. The selected image is below.

ic_crop_original_black_24dp

Can you solve the problem by using Clip Art resources?

Hemp answered 21/3, 2019 at 2:56 Comment(1)
I could do that for that photo image, but since the other image is not in clip art, I would still have an issue.Reform
S
0

It is mainly due to some incompatibility in vector asset importer and the svgs. You can always find another resources or use same resource by optimizing with SVGOMG to tune the SVG and try importing again.

Sleuth answered 21/3, 2019 at 3:0 Comment(1)
I tried SVGOMG but unfortunately it still looks distorted. As for trying different resources, I might have to try that, though I assumed resources directly from the Material site wouldn't have any issues.Reform
S
0

It Could be a Design issue. Vector Asset Studio doesn't support all PSD file features. The following list summarizes supported and unsupported PSD characteristics, as well as some conversion details.

https://developer.android.com/studio/write/vector-asset-studio#PSD

Songful answered 21/8, 2021 at 7:48 Comment(0)
H
-1

It may be faster solution to fix the distorted point with xml after importing SVG.

before

M19,5v14L5,19L5,5h14m0,-2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14.14,13.86l-3,3.87L9,13.14 6,17h12l-3.86,-5.14z

after

M19,5v14L5,19L5,5h14m0,-2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14.14,11.86l-3,3.87L9,13.14 6,17h12l-3.86,-5.14z
Hemp answered 21/3, 2019 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.