Thursday, February 10, 2011

Accelerating Android XML Layouts with AutoHotkey - NOW WITH VIDEO!


I know that building your XML layouts can be frustrating at times. This won't magically build your UI's for you, but it will speed you on your way.
AutoHotkey
If you haven't heard of AutoHotkey, go and learn about it: http://www.autohotkey.com/. It's one of the most useful tools out there. The basic concept is that you can program your own hotkeys for use all over windows. You can manipulate text, replace text, call other macros and scripts, build custom gui's and much more. This is only available for Windows, sorry everyone else. You will need to download and install this application first.
The Script
AutoHotkey is designed to allow you to write your own custom scripts and will auto-load any scripts on your machine with the .ahk extension. You can get my script here: android helper script. Once you have AutoHotkey installed, just download my script, rename it with an .ahk extension, double click on it and you'll be good to go.
How it works

Once the script is installed go into Eclipse or whatever other environment you code in and create a new xml layout file. Call it test_layout.xml or something. Once there follow these steps:
  • type: xml_heading^
  • press enter
  • type: relative_layout^
  • press enter
  • move your cursor to right after the text "
  • make a few lines inside your relative layout and indent and type: button^
  • press enter
  • type: image_view^
  • press enter
You get the idea. Here is a list of all the XML elements the script can input:
  • LinearLayout
  • RelativeLayout
  • FrameLayout
  • WebView
  • Button
  • ImageView
  • EditText
  • TextView
  • TableLayout
It can also insert some other random stuff:
  • xml heading thing at the top of an xml document(xml_heading^)
  • android namespace(android_namespace^)
  • the onCreate method in an activity. I hate typing that out every time! (on_create^)
That's it so far. For the layouts and widgets, the format for the hotkey replacements is just underscored names. If you add to the script, be kind and post it back to this thread. Thanks for reading. Enjoy


Update: I've uploaded a screen cast to YouTube. http://www.youtube.com/watch?v=c7EdFXb6-rw

1 comment:

  1. I am an accidental entrepreneur, making tons of money from my home. People like you have helped me aware of the vast possibilities that online marketplaces have to offer. Your article is one of the most useful write-ups that are best suited for freelancers. I was once a nine-to-five office-goer. It all changed when one day I stumbled upon websites like social media expert , bespoke eyecatching flyer design, and www.zopthemes.com, where I sell my skills now. There are loads of online buyers waiting to pay you for your talent/hobby. Check them out and make quick money - the legal way.

    ReplyDelete