I am looking for a thorough Android naming convention suggestion. I found a little bit here:
http://source.android.com/source/code-style.html#follow-field-naming-co
CONSISTENCY
Everyone (unless working in teams) will have their own convention and which one you choose does not matter. Making sure it is consistent throughout the whole application does matter.
STRUCTURE
Personally, I use a naming convention like this as it runs from the class name down to component and is consistent throughout the xml:
<ClassName>
<ClassName>**Activity**
classname_activity
classname_activity_component_name
An example of this would be OrderActivity.class
, order_activity.xml
, order_activity_bn_cancel
. Notice all the XML is in lowercase.
ABBREVIATING LAYOUTS
If you would like to use shorter names to keep the code tidier; then another method can be to abbreviate ALL the names in XML aswell as the layouts.
An example of this would be OrderActivity.class: ord_act.xml, ord_act_bt_can, ord_act_ti_nam, ord_act_tv_nam. I break down the names into three but this depends how many similar names you have
ABBREVIATING COMPONENT TYPES
When abbreviating component types try to keep these consistent too. I normally use two letters for the component type and three letters for the name. However sometimes the name will not be necessary if that is the only element of that type in the layout. The principle of the ID is to be unique
nam_act_component_nam
COMPONENT TYPE ABBREVIATIONS (This list shows two letters which is plenty)
Frame Layout: fl
Linear Layout: ll
Table Layout: tl
Table Row: tr
Grid Layout: gl
Relative Layout: rl
Text View: tv
Button: bt
Check Box: cb
Switch: sw
Toggle Button: tb
Image Button: ib
Image View: iv
Progress Bar: pb
Seek Bar: sb
Rating Bar: rb
Spinner: sp
WebView: wv
Edit Text: et
Radio Group: rg
List View: lv
Grid View: gv
Expandable List View: el
Scroll View: sv
Horizontal Scroll View: hs
Search View:* se
Tab Host: th
Video View: vv
Dialer Filter: df
Include: ic
Fragment: fr
Custom View (other): cv