theUturn theUturn - 1 month ago 6
Android Question

How to create vector drawables for android?

I am new to

vector drawbles
.

I can see that the default
vector drawables
provided with android studio like
ic_menu_gallery
,
ic_menu_camera
, etc. are working great. So I tried to create my own
vector drawables
by converting my
png images
to
svg
first and using the path and fill values to make vector drawables i.e replaced the
android:pathData
for d and
android:fillColor
for fill tag in svg files. It somehow gave vector drawables but distorted or currputed looking.

If I am not taking the right approach please suggest me.

Answer

You can use Android Studio. Convert png to svg file online tools PNG to SVG
File - > New -> Vector Asset

You can chose Material Icon or Local SVG file

For SVG color can use :

  <ImageButton
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:id="@+id/button"
    android:src="@drawable/ic_more_vert_24dp"
    android:tint="@color/primary" />

Or

imageView.setColorFilter(getResources().getColor(android.R.color.black), PorterDuff.Mode.SRC_IN);
Comments