I have been trying to find an answer to this question for months, but even Android documentation directs to Java naming convention document which does not say anything (which is logical) about Android-specific elements like TextView, EditView, etc. It also seems that stackoverflow does not have an answer to this question. Not to mention that Google demo projects use kindergarten namings, like myButton, yourEditView, theirTextView, etc. :)
So what document do you use as a source for Android-element naming convention? We've tried developing our own naming conventions, but it just did not feel right (we got ugly abbreviations).
We would like to create such document for our in-house usage, but we were stuck before we've even begun.
Use the names The only way to make the names stick is to use them repetitively. Design systems evolve very quickly and your language should keep up with it. So the more you use the names everyday, the easier it will be to get used to the new names that show up as your system evolves.
Are you referring to the ids in the xml layouts?
I name mine based on the layout name, type of view and functionality. For example if I have a signup.xml
layout, I would name the elements inside:
[layout]_[view]_[object's purpose]
signup_text_user
signup_edit_user
signup_text_pass
signup_edit_pass
signup_btn_login
etc
The names are kind of long, but it's easy to look for the ids in code, since all my signup elements have a "signup_" prefix, and all my textviews inside the layout have "text_" and so on.
try this:
http://source.android.com/source/code-style.html#follow-field-naming-conventions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With