Android id naming convention: lower case with underscore vs. camel case

The device will not complain if you use camel-case id names. For my first application I wrote all the ids in camel-case because I think it appears better in the Java code that way, and it works just fine.

I am slowly changing my mind on camel-case, though, because you end up with two different naming conventions – for example:

// This must be undescored due to naming constrictions
setContentView(R.layout.my_long_layout_name);

// Now this looks a little out of place
findViewById(R.id.myLongSpecificId);

I, too, wonder about the standards here. Google is inconsistent in their examples; sometimes they use all lowercase, sometimes they insert underscores, and sometimes they use camel-case.

Leave a Comment