Category Archives: ADT

ADT Graphical Layout tool and SCM systems

Well, most of you android developers encountered this problem. The graphical layout designer in the ADT (Android Developer Tool – the eclipse plugin) creates every element in the XML as one line. You might ask, why is it a problem? well, in most cases, it is not. But there is one annoying thing that makes this feature/bug or whatever you want to call this a real time consumer. Unless you are a solo Android developer that saves his code in a local or remote storage as is, you probably use some kind of SCM (Source Control Management) system (e.g. git, svn, cvs, tfs, clearcase and the list goes on and on). Most (if not all) of these systems and their diff tools (also most of the diff tools I encountered) use line comparison. They tell you if you added/removed/edit a line. In case you edit a line, it marks the parts of the line you edited. This is all nice when you edit the text code yourself. But in the GL (Graphical Layout) you don’t. And then, if you changed one property of an element using the GL, you will see it in the SCM as an edited line. The thing is, now you need to go over the whole element (that sometimes has several properties) and see which property exactly you changes. And let’s say, for example, that you changed two properties. One is at the beginning of the line and the other at the end. How easy it would be to miss that second property? Basically, what the GL does is to eliminate many of the advantages of SCMS.

In the past, I usually chose between two options:

  1. Not use the GL (not always possible since I don’t remember all the properties by heart).
  2. After using the GL, go over the file and add line breaks manually.
I wanted to use the auto formatting tool of eclipse, but it always looked bad. Here it how it looked before:
And After:
After a bit of digging in the eclipse preferences by my colleague he found the solution: going to preferences -> XML -> XML Files -> Editor and checking the “Split multiple attributes each on a new line” and after pressing Ctrl+Shift+F voila:
No more hard work setting the text to align as i want it.