Eugene Eugene - 8 months ago 42
Android Question

Are there conventions on how to name resources?

Are there conventions how to name resources in Android? For example, buttons, textViews, menus, etc.

Ian Ian

I don't know whether there are any official recommendations.

For ids in my layouts with widgets and containers, I use the convention:


I do the same strategy for any dimens, strings, numbers, and colors I use in those layouts. However, I do try generalizing. e.g if all buttons have a common textColor, I won't prefix the name with the layout. The resource name would be 'button_textColor'. If all textColors are using the same the resource it will be named 'textColor'. For Styles, this is usually the case as well.

For menu resources i use:


Animations are only different as you cannot use uppercase letters. Same goes for drawable xml resources, i believe.