Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android tool to generate selector xml for buttons

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

like image 332
Entreco Avatar asked Dec 07 '11 23:12

Entreco


2 Answers

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.

like image 125
Cata Avatar answered Sep 18 '22 03:09

Cata


I have created even better tool for generating drawable selectors. It's a Android Studio/IDEA plugin called SelectorChapek. You just click the 'drawable-xhdpi' folder, select 'Generate Android Selectors' and all your selectors appear automagically in the 'drawable' folder! (assuming your resources are appropriately named)

Howto, source & download: https://github.com/inmite/android-selector-chapek

Screenshot

like image 30
David Vávra Avatar answered Sep 20 '22 03:09

David Vávra