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 size
- scalability (It scaled without loss of display quality)
- height and width can be changed easily
- support transparency
- color can be changed
In this article, we will discuss how to convert SVG and PSD image files into XML Vector Drawable and display it in the Android app.
Steps for Converting SVG, PSD images to Vector Drawable File
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Step 2: Converting Files
- Right Click on the app -> res, then select New->Vector Asset
- Asset Studio Window will open, select the Local file (SVG, PSD)
- Locate the SVG or PSD file in the Path. (Download file)
- Change the Name, Size, Opacity of the file, and click on Next. Now your SVG file is converted into an XML file.
- When you click on the ic_freesample.xml file following is the auto-generated XML code.
Step 3: Showing image in the Android app
- Now we will show this XML vector drawable file in the app.
- Below is the code of the activity_main.xml file.
- MainActivity.java file
There is nothing to do with the MainActivity.java file.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- How to Create Drawable Resource XML File in Android Studio?
- Android | AdMob Banner Ads for Android Studio
- Android | AdMob Interstitial Ads for Android Studio
- Android | How to Create/Start a New Project in Android Studio?
- How to install Android Applications in Mobile Phone without USB Cables using Android Studio
- How to implement Swipe Down to Refresh in Android using Android Studio
- How to Add OpenCV library into Android Application using Android Studio?
- How to Add Local HTML File in Android Studio?
- Toasts for Android Studio
- Guide to Install and Set up Android Studio
- How to build a simple Calculator app using Android Studio?
- 10 Important Android Studio Shortcuts You Need the Most
- How to scale different Views to all screen sizes in Android Studio?
- How to create a Stopwatch App using Android Studio
- How to Upload Project on GitHub from Android Studio?
- How to build a simple music player app using Android Studio
- Logcat window in Android Studio
- Guessing the Number Game using Android Studio
- How to populate RecyclerView with Firebase data using FirebaseUI in Android Studio
- How to Generate Signed Apk in Android Studio?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.