Is there a way to preview a vector drawable

AndroidSvg

Android Problem Overview


Short of building and installing my app, is there a way to preview a vector drawable xml file?

I've built it into a small test app in Android Studio, and can preview it as part of the layout file, but I was hoping for a simpler way.


Edit: here's what my drawable.xml file looks like:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">

    <group>
        <path
            android:fillColor="#f5a625"
            android:strokeColor="#000000"
            android:strokeWidth=".5"
            android:pathData="M0,0l18,0l6,6l0,10l-24,0z" />
    </group>
</vector>

Android Solutions


Solution 1 - Android

There is a Preview tab especial for that at the right side (since Android Studio 2.0):

enter image description here

Solution 2 - Android

If the Preview window doesn't automatically show. You can manually show the Preview window by going to View -> Tool Windows -> Preview in Android Studio's menu.

Solution 3 - Android

There is a way to preview all the vector drawables in your project at the same time using the Android Studio plugin at https://plugins.jetbrains.com/plugin/10741-vector-drawable-thumbnails

just go to Settings -> Plugins -> Browse Repositories and search for "Vector Drawable Thumbnails"

Solution 4 - Android

Android Studio 1.4 lets you preview VectorDrawables. Just double-click on them in your res/drawable folder.

Solution 5 - Android

You can quickly search through vector drawable previews in Android Studio by going to design view in the xml editor and under properties, clicking the ... button next to srcCompat

Solution 6 - Android

When you open the vector drawable in Android Studio, there are controls available in the upper right corner of the window. You can choose to switch between Code, Split and Design.

However these controls only show up if the vector drawable is used in the currently selected build variant. The only way I could see a preview for drawables from other build variants, was to switch to that specific build variant.

android studio controls

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEdward FalkView Question on Stackoverflow
Solution 1 - AndroiddasarView Answer on Stackoverflow
Solution 2 - AndroidJadeView Answer on Stackoverflow
Solution 3 - AndroidIgnacio Tomas CrespoView Answer on Stackoverflow
Solution 4 - AndroidPaul LeBeauView Answer on Stackoverflow
Solution 5 - AndroidCarson HolzheimerView Answer on Stackoverflow
Solution 6 - AndroidWirlingView Answer on Stackoverflow