Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vector Drawable in the circle

is there an easy way to generate Vector Drawable that is a circle with the icon inside from the existing vector drawable?

Example: existing vector drawable

generated vector drawable, circle with empty icon inside

like image 281
qbait Avatar asked Mar 20 '18 18:03

qbait


People also ask

What is vector drawable?

A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability.

What is vector asset in android studio?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.


1 Answers

I would suggest something like this:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    android:gravity="fill"
    android:drawable="@drawable/ic_brightness_1_black_24dp"

    />
    <item
        android:gravity="center"
        android:drawable="@drawable/ic_call_black_24dp"
        android:top="20dp"
        android:bottom="20dp"
        android:left="20dp"
        android:right="20dp"
        />

</layer-list>

The resources with ids ic_brightness_1_black_24dp and ic_call_black_24dp are imported vector drawables.

ic_brightness_1_black_24dp:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#303F9F"
        android:pathData="M12,12m-10,0a10,10 0,1 1,20 0a10,10 0,1 1,-20 0"/>
</vector>

and ic_call_black_24dp:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FFFFFF"
        android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"/>
</vector>
like image 115
DimDim Avatar answered Oct 17 '22 10:10

DimDim