I\'m trying to import some icons from Material Vector package in Vector Asset Studio.
But they come with padding.
Why does this happen and how can I
You can adjust for any "implicit" padding that may be contained within a VectorDrawables
source image (.SVG
, .PSD
) by setting your ImageViews
android:scaleType
to the appropriate value so it can handle the padding that is secretly contained in the VectorDrawables
source image. You will also need to set android:adjustViewBounds="true"
.
For example, lets say your VectorDrawable
has some really annoying padding
at the start of the image when you display it. You have no idea why it's there because you aren't setting any android:paddingStart
on the ImageView
... what you need to do is set the ImageViews
android:scaleType
to fitStart
and android:adjustViewBounds
to true
.
tl;dr
Adjust your ImageViews
android:scaleType
to handle any "implicit" padding that is contained in your VectorDrawable
s source file (.SVG
, .PSD
). Also set android:adjustViewBounds="true"
.
Quick Example:
android:adjustViewBounds="true"
android:scaleType="fitStart"
app:srcCompat="@drawable/vector_with_implicit_padding_at_start"
/>
This will remove that annoying "implicit" padding that was at the start of your VectorDrawable
.
Note: Adjust the android:scaleType
according to your rendering needs.