简体   繁体   中英

Is there a way to preview a vector drawable

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>

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

在此处输入图片说明

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.

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"

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

您可以通过在 xml 编辑器中的设计视图和属性下,单击 srcCompat 旁边的 ... 按钮,在 Android Studio 中快速搜索矢量可绘制预览

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.

安卓工作室控件

My solution for this was: right click on the.xml file, then click "Open in Right Split". The preview should appear on the right side of the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM