dimanche 22 février 2015

Android - How to implement 9 patch?

I've created some 9-patch image files using Photoshop and the Draw9Patch tool, but as I tried to implement the images, it seems like a bust. I was following this tutorial (http://ift.tt/1LtqtuJ). Any reason this may not work? I pasted the 4 images to the drawable-hdpi, and created a new values XML called "buttons.xml" and I placed the code in that XML file:



<selector xmlns:android="http://ift.tt/nIICcg">
<item android:drawable="@drawable/default_disabled" android:state_enabled="false"/>
<item android:drawable="@drawable/default_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/default_focused" android:state_focused="true"/>
<item android:drawable="@drawable/default_normal"/>
</selector>


"default_(state)" are the names of the files (with .9.png extension). And I attempted to set the background of a button to android:background="@drawable/buttons"


Where did I go wrong?


Aucun commentaire:

Enregistrer un commentaire