What naming conventions do you use for resource files and IDs and what benefits do they bring?
It’s very easy for example to end up with a view ID like “activity_settings_location_text_label” but quickly becomes unmanageable and messy. I’ve not seen any guidance from Google on this, did I miss it?
Resources can be “grouped” using hierarchical naming, but what structure works best for each resource type? String, color, dimens, layouts, includes, etc
My naming is currently fairly ad-hoc, and it’s clear I need better structure (particularly so I can find IDs more easily using the IDE’s code-completion).
The most important thing to remember, I think, is that it’s perfectly fine to use the same ID across multiple layouts. For example,
@id/title_baris clean and generic and works, and so much simpler than@id/settings_title_bar,@id/home_screen_title_bar,@id/search_title_barand so on.I also like to name layouts destinated for activities as
@layout/activity_homeand@layout/activity_searchetc. Drawables and icons should adopt the same standards as Android uses, i.e.@drawable/ic_btn_explodeand@drawable/ic_dialog_exploded.Includes can be tricky, but simpler ones which consist of only a few elements and serve a single, precise purpose tend to end up as
@layout/loadingor@layout/error_message.I’m still working on naming strings sensibly, but again short, concise names make the whole process a lot easier.