Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you name UI elements?

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.

like image 427
sandalone Avatar asked Aug 19 '11 12:08

sandalone


People also ask

How do you name a project UI?

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.


2 Answers

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.

like image 165
f20k Avatar answered Sep 18 '22 01:09

f20k


try this:

http://source.android.com/source/code-style.html#follow-field-naming-conventions

like image 25
Vineet Shukla Avatar answered Sep 20 '22 01:09

Vineet Shukla