How to preview xml drawable?
Asked Answered
E

10

44

I'm working on pretty complex xml drawable and i was wondering if there is any tool/plugins which allow me to preview my drawable ?

I'm looking for something similar to the "Graphical layout" tab available for layout.

For example if i have something like this :

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:left="0dp" android:right="0dp"> 
        <shape android:shape="rectangle">

            <gradient android:angle="-90" android:startColor="#2B2B2B"
                android:endColor="#000000" />

        </shape>
    </item>
    <item android:top="1sp" android:bottom="26sp" > 
        <shape android:shape="rectangle">
            <solid android:color="#10ffffff"/>
    </shape>

    </item>
</layer-list>

How can i preview the shape and gradient ? And i'm probably dreaming , but is there any graphical tools to build a drawable ?

Electrolysis answered 13/6, 2012 at 15:22 Comment(0)
P
87

In Android Studio do this: View -> Tool Windows -> Preview

Photochemistry answered 17/5, 2015 at 10:1 Comment(2)
Would it be obvious for Android users to know which tool you are referring to?Kerge
@Electrolysis I recommend to accept this answer as correct.Quidnunc
W
9

Android Studio has support for this starting with version 0.3.2: http://tools.android.com/recent/androidstudio032released

Willhite answered 5/12, 2013 at 22:55 Comment(0)
P
7

Click on PREVIEW on the right side of the window.

enter image description here

Prepuce answered 23/3, 2016 at 18:43 Comment(0)
K
5

In Eclipse Create new layout with root LinearLayout. Open Outline view. In properties table find View.Background. Press button ... Now you can chose Color and Drawable resources and there is small preview.

Preview in Eclipse

Kenton answered 24/9, 2013 at 15:42 Comment(0)
T
4

Android Studio offers a nice plugin named

"Vector Drawable Thumbnails"

This adds a nice overview over all vector drawables in your project. Just have a look at the side bar and open the view. You will get a thumbnail table of them.

Vector Drawable Thumbnails

Tarver answered 22/2, 2019 at 13:30 Comment(0)
I
3

Android Studio 2X

  1. View -> Tool Windows -> Preview
  2. Or click on Preview on the right side

enter image description here

Impresa answered 15/3, 2017 at 13:38 Comment(0)
D
2

Another possibility:

Just create a new layout "test", goto graphical layout, create a button inside (or any view), and assign the drawable to the button's background. The drawable is rendered (its normal state).

Deadbeat answered 13/3, 2014 at 0:43 Comment(0)
R
1

One way to preview the resources is by using the Resource Manager in Android Studio. It's visible as a separate tab:

PrintScreen

Recruit answered 17/4, 2020 at 10:51 Comment(0)
B
1

The Preview options mentioned in previous answers aren't there in Android Studio 4.0. Look for this segmented control in the top-right of the editor tab instead.

Android Studio 4.0.1 showing code/split/design control

Bertrand answered 6/4, 2021 at 16:27 Comment(0)
C
0

If you would like to preview selector you can find tabs with states on Preview Panel enter image description here

Chokefull answered 2/2, 2018 at 11:44 Comment(2)
how do you get this states tabs? currently they is no visible way of getting thosePoore
4 years later, running Android Studio Giraffe 2022.3.1 and I can't find where to turn on this states bar either.Flavorous

© 2022 - 2024 — McMap. All rights reserved.