Change code formatting and fixed bug with the sample app

I've changed the code style to be a little more in-line with the Google AOSP code style guidelines. More specifcally, I've changed it so all lines are less than 100 characters as outlined here: https://source.android.com/source/code-style.html#limit-line-length

I have also fixed an issue with the sample app where the centre gravity field had no hint defined within the XML.
spaces after `if` should be left IMHO.