How to preview xml drawable?
-
14-06-2021 - |
Question
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 ?
Solution
In Android Studio do this: View -> Tool Windows -> Preview
OTHER TIPS
Android Studio has support for this starting with version 0.3.2: http://tools.android.com/recent/androidstudio032released
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.
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).
One way to preview the resources is by using the Resource Manager in Android Studio. It's visible as a separate tab: