Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Use SVG Vector Drawables in Android?

  • Last Updated : 11 Aug, 2021

SVG stands for Scalable Vector Graphics. It is used for rendering two-dimensional images on the internet. SVG is used for high-quality images that can be scaled to any size. we can use SVG files in android too. SVG can be used for icons, for creating images for creating beautiful UI. In this post, we are how to see create vector graphics in the Android studio

Step by Step Implementation of Creating SVG Vector

Step 1: Create a new project

Step 2: Right click on res –> drawable –> new –> vector asset

Step 3: By default clip art will be selected 

Step 4: Select local file

Step 5: After selecting the local file you will see this screen

Step 6: Locate your image file location. After that click on finish.

Step 7: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 


      <!--creating imatgeview-->
    <!--this attribute is used for showing image-->
    <ImageView android:id="@+id/imageView" 
  <!--creating button-->
    <Button android:id="@+id/gfgButton" 
            android:text="Tap here to see gfg icon" 

Step 8: Working with the file

Go to the file and refer to the following code. Below is the code for the file. Comments are added inside the code to understand the code in more detail.


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener
    ImageView imageView;
    protected void onCreate(Bundle savedInstanceState) {
        Button b = findViewById(;
        imageView = findViewById(;
        // registering on click listener
    public void onClick(View v) {
      // when we will click on button we will see image
      // therefore using View.VISIBLE to make it visible


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!