Gravity value must be stored in a resource file because I have a multi-language app. (Arabic/English) which will affect the layout direction from ltr to rtl.
I used to do the same approach with eclipse adt successfully.
Error says: Cannot resolve flag. Validate resource references inside android xml files.
I recognised later that even that line highlighted with red which is the color for errors it can compile and run.
Apparently since the new SDK API supports language directions by providing the supportRtl attributes in the manifest. Google tries to encourage developers to use it and discourage them to keep using gravity in this way to implement languages direction. That's why it marked with Red.