Open In App

How to Add Vector Assets in Android Studio?

Last Updated : 18 Apr, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Vector Assets in Android Studio helps to add material icons and import Scalable Vector Graphics and Adobe Photoshop Document files into your project as vector drawable resources.

How Vector Asset is different from Image Asset?

Image Asset Studio helps us create different types of icons with different densities and shows us exactly where they’ll be placed in our project. It includes tools for adjusting our icons and adding backdrops, all while displaying the result in a preview pane, so they appear exactly as we intended. Vector Asset Studio helps to add a vector graphic to our project as an XML file that describes the image.

Problem using PNG’s

The PNG format can surely handle high-resolution photos. PNG format is a lossless web format. Hence, file sizes tend to get very large. If we want to work with photos on the web, we should always try to continue with JPEG.  And the main issue for printing a .png file is its inherent color profile. The colors of the images may be a little dull since the printer has to interpret a different color language. Each PNG asset which we use is a certain density specific. Therefore, we have to deal with different versions of the same image for different screen sizes. To get rid of such problems we use vector assets. 

Bitmap vs Vector

There are the following differences between Bitmap and Vector:

  1. Bitmap uses pixels while vector uses geometric shapes.
  2. Bitmap images are comparatively larger than vector images.
  3. Bitmap type is suitable for photographs while vector type is suitable for logos, clip arts, and icons.
  4. Resizing the images affects the resolution in the case of Bitmap images which resolution is preserved in Vector images.
  5. Bitmap images can be edited using Adobe photograph while Vector images can be edited using Adobe Illustrator.

Benefits of Vector Assets

Image scalability is the major advantage of using the vector drawable. The same file can be resized for different screen sizes without loss of image quality which results in smaller APK files and less developer maintenance. We can also use vector images for animation. 

How do vector assets render?

The vector assets are first compiled to binary format at compile time and then at runtime. Next, the application is needed to load this up, generates a model object from binary code, and perform some canvas operations to draw the individual paths to the screen. 

Vector Formats

There are the following vector file formats: 

  1. .ai: abbreviation for Adobe Illustrator which is commonly used to print media and digital graphics.
  2. .eps: abbreviation of Encapsulated PostScript which doesn’t support transparency in the way .ai format does.
  3. .pdf: abbreviation of  Portable Document Format which is built for the exchange of documents across platforms.
  4. .svg: The Scalable Vector Graphics format is based on XML. It’s useful for the web, where it can be indexed, searched, and scripted.

Step by Step Implementation 

Step 1: Right-click on drawable > New > Vector Asset 

After clicking on Vector Asset a new dialog box is opened that is shown below.

Step 2: Click on Clip Art and Search for the Icons and click ok button

Step 3: Change the color of the icon

Icon color can be changed either by directly adding color code or by adjusting the color using brightness and then click on choose button.

Step 4: Click Next 

Step 5: Now Click on Finish Button

Step 6: Icon is created in the drawable folder as shown in the image


Similar Reads

Assets Folder in Android Studio
It can be noticed that unlike Eclipse ADT (App Development Tools), Android Studio doesn’t contain an Assets folder in which we usually use to keep the web files like HTML. Assets provide a way to add arbitrary files like text, XML, HTML, fonts, music, and video in the application. If one tries to add these files as "resources", Android will treat t
4 min read
How to fix "Android Studio doesn't see device" in Android Studio?
In Android Studio, sometimes the list of devices and emulators doesn't list your physical device when you try to plug it in. Or you may have faced a situation when you plugged the phone in for the first time, no dialog appeared asking if you trust the computer. But the laptop is already allowed to connect to the mobile device. However, the button R
4 min read
How to Fix "Android studio logcat nothing to show" in Android Studio?
Logcat Window is the place where various messages can be printed when an application runs. Suppose, you are running your application and the program crashes, unfortunately. Then, Logcat Window is going to help you to debug the output by collecting and viewing all the messages that your emulator throws. So, this is a very useful component for the ap
2 min read
How to Add OpenCV library into Android Application using Android Studio?
OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries,
3 min read
How to Add Audio Files to Android App in Android Studio?
The audio file format is a file format for saving digital audio data on a computer system and all are aware of audio files. So in this article, we are going to discuss how can we add audio files to the android app. There are three major groups of audio file formats: Format Name Description Examples Uncompressed audio formatsUncompressed audio forma
3 min read
How to Add Firebase Analytics to Android App in Android Studio?
Analytics is one of the important tools that developers should definitely used while building their applications. It is very helpful to target your apps for various audience ranges and to track on which screen the users are spending a long time. So it is one of the important features which one should not miss adding while building any Android Appli
4 min read
How to Add Resource File in Existing Android Project in Android Studio?
Android resource file is a file that stores resources needed for the UI part of an android application. Like: Layout files, drawable files, etc. In the android application, it is very often that we need another resource file for another purpose in the existing application. There are many types of resource files Layout files, Drawables, Menus are so
1 min read
How to Convert SVG, PSD Images to Vector Drawable File in Android Studio?
In order to use the SVG (Scalable Vector Graphics) or PSD (Photoshop document) image file in your android studio project, you have to first convert them into an XML (Vector Drawable) file. Why XML (Vector Drawable) file? small in sizescalability (It scaled without loss of display quality)height and width can be changed easilysupport transparencycol
3 min read
How to Add Local HTML File in Android Studio?
HTML stands for HyperText Markup Language. It is used to design web pages using a markup language. HTML is the combination of Hypertext and Markup language. Hypertext defines the link between the web pages. A markup language is used to define the text document within the tag which defines the structure of web pages. HTML is a markup language that i
3 min read
How to Install Genymotion Emulator and Add it’s Plugin to Android Studio?
Genymotion is an Android Emulator that is faster than the Android Studio Emulator. Genymotion emulator offers a wide range of virtual devices for development, test, and demonstration purpose. It has a very simple user interface and one can directly use it from Android Studio by installing its plugin only once. The Genymotion plugin for Android Stud
4 min read
Article Tags :