SEQUENCE
Everyone (if not working in a team) will have their own agreement, and which one you choose does not matter. Make sure that it is consistent throughout the application.
STRUCTURE
Personally, I use a naming convention like this one, since it works from class name to component and is the same for all xml:
- CLASS :
<ClassName> - ACTIVITY :
<ClassName>**Activity** - LAYOUT :
classname_activity - Component Identifiers :
classname_activity_component_name
An example of this would be OrderActivity.class , order_activity.xml , order_activity_bn_cancel . Note that all XML letters are lowercase.
Short layouts
If you want to use shorter names to keep the code clean; then another method may be to reduce ALL XML names as well as 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 divide the names into three parts, but it depends on how many similar names you have
REDUCED TYPES OF COMPONENTS
When reducing component types, try to keep them consistent as well. I usually use two letters for the type of component and three letters for the name. However, sometimes a name is not required if this is the only element of this type in the layout. The principle of ID must be unique
- IDS COMPONENT:
nam_act_component_nam
ABBREVIATIONS OF COMPONENT TYPE (two letters are shown in this list, which are quite enough)
Frame Structure: fl
Line Layout: ll
Table Location: tl
Table row : tr
Grid Location: gl
Relative layout: RL
View Text: TV
Button: bt
Checkmark: cb
Switch: SW
Toggle Button: tb
Image Button: ib
View Image: iv
Progress Bar: pb
Search bar: Sat
Rating bar: rb
Spinner: sp
WebView: wv
Edit Text: et
Radio Group: rg
Browse List: lv
Type of mesh: G.V.
Expandable Watch List: el
Scroll View: SV
Side Scrolling: hs
Search: * se
Tab Host: th
Watch video: vv
Dialer Filter: df
Include: ic
Fragment: fr.
Custom View (other): cv
Jethro Feb 08 '16 at 14:50 2016-02-08 14:50
source share