How to Use SVG Vector Drawables in Android?
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.
Step 8: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.