Android tool to generate selector xml for buttons
Asked Answered
D

3

19

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

Dexedrine answered 7/12, 2011 at 23:14 Comment(0)
P
16

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.

Papke answered 10/12, 2011 at 0:44 Comment(1)
I apologize, I moved my blog from blogger to a private host and I forgot to update the url here too.. I updated the url :)Papke
B
16

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

Brownfield answered 20/8, 2013 at 22:5 Comment(1)
I tried your plugin, all it gives is "Selectors were generated into 'drawable' folder" but nothing is there generated into drawable folder!Petrel
D
1

How about this? I use it to generate holo style xml file.

Duple answered 26/3, 2014 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.