Android Unusual Behaviour – Nine Patch PNG’s
I was doing some development on an app and got some weird behaviour where 3 buttons, all of the same background would line up as expected in eclipse and the emulator, but when I inserted a different button in the centre, it messed up when ran on the emulator.
I played around with a number different layouts trying to work out how I was going to fix this, assuming it was just my layout that was playing up. But I got curious and played around with the 9 patch png used for the new button and quickly realised that was the problem. To explain further, compare the left image (The layout shown in eclipse, how I wanted the view to display, and the right is how it displayed when inflated in the emulator [Ignore the button widths - that was me playing around, just look at the heights]).

The problem was that android was putting in an empty space for text but didn’t know where to put it as I hadn’t set an area the bin image could put content, as soon as I put this in the 9 patch png, I got the required result.
So if anyone gets weird results, play with the 9.png if you are using them as this can mess up your layout as well as the actual layout itself.