android 9 patch drawable xml

Ben picture Ben · Jul 8, 2010 · Viewed 13k times · Source

Is there a way to define a 9 patch drawable in an android xml file? The reason I ask, is that when you apply a scale animation to a drawable w/ a stroke on it, the stroke appears to thicken. I'd like to make the stroke stay the same size as the animation plays...

Answer

Lior picture Lior · Dec 14, 2010

Yes, but this is done mostly to define dithering for the 9-patch. Here's an example:

<?xml version="1.0" encoding="utf-8"?>
<nine-patch
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/your_drawable_here"
        android:dither="true"
        >
</nine-patch>

For more information see the documentation