Android tool to generate selector xml for buttons

Entreco picture Entreco · Dec 8, 2011 · Viewed 17.6k times · Source

I was wondering if anyone knows of a tool to generate xml selector files for your custom buttons. I'm getting a bit tired creating buttons, convert them to .9.png files and then copying and pasting a custom selector in xml...

I am aware of these tools:

http://www.androidicongenerator.net/

http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html

As handy as they are in generating assets/resources, I miss the option to select 4 images and generate a ready-to-use selector xml, which outputs something like:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- pressed -->
    <item android:state_pressed="true" android:background="@drawable/img_pressed" />
    <!-- focused -->
    <item android:state_focused="true" android:background="@drawable/img_focussed" />
    <!-- default -->
    <item android:background="@drawable/img_default" />
</selector>

I am considering in creating one myself, but can't believe no-one already did it :)

Thanks

Answer

Cata picture Cata · Dec 10, 2011

inspired from this post I made a XML StateList generator, you can find it here, I would love to see if somebody have better generator.

Have a great day!

Made an update to my Android State list generator, now you can make use of all the supported states.