Naming Convention for Android Development
Package Structure
See this Package by feature, not layer
Naming Convention for Classes
<PRODUCT_NAME>[Link] - for Application class
<NAME>[Link] - for activity class
<NAME>[Link] - for adapter class
<NAME>[Link] - for fragment class
<NAME>.java - for model class
<NAME>[Link] - for content provider class
<NAME>[Link] - for service class
<NAME>[Link] - for broadcast receiver class
<NAME>[Link] - for utility class
<NAME>.java - for custom view class
Short Name of Android Widgets
Note: You should use more meaningful names than these short names unless you have two
or more same kind of views in the same place.
aclock - AnalogClock
actv - AutoCompleteTextView
btn - Button
cal - CalendarView
chb - CheckBox
chtv - CheckedTextView
chron - Chronometer
dp - DatePicker
edt - EditText
explv - ExpandableListView
fl - FrameLayout
gl - GridLayout
grv - GridView
hsv - HorizontalScrollView
imb - ImageButton
ims - ImageSwitcher
imv - ImageView
ll - LinearLayout
lsv - ListView
ctlr - MediaController
mactv - MultiAutoCompleteTextView
np - NumberPicker
pm - PopupMenu
pw - PopupWindow
pgb - ProgressBar
rb - RadioButton
rg - RadioGroup
rtb - RatingBar
rl - RelativeLayout
rv - RemoteViews
scv - ScrollView
schv - SearchView
skb - SeekBar
sap - ShareActionProvider
space - Space
spn - Spinner
stv - StackView
sw - Switch
tabh - TabHost
tabc - [Link]
tl - TableLayout
tr - TableRow
twg - TabWidget
tclock - TextClock
tsw - TextSwitcher
txv - TextView
tp - TimePicker
toast - Toast
tgb - ToggleButton
vdv - VideoView
vf - ViewFlipper
vsw - ViewSwitcher
Naming Convention for Image Files
See this Android-Cheatsheet-For-Graphic-Designers#Naming Convention
XML Files (res/anim)
<INTERPOLATOR_NAME>_interpolator.xml - for custom interpolator
<ANIMATION_NAME>.xml - for custom animation
XML Files (res/animator)
<ANIMATOR_NAME>.xml- for custom animator
XML Files (res/color)
selector_<COLOR_NAME>.xml - for color state list
XML Files (res/drawable)
bmp_<BITMAP_NAME>.xml - for bitmap file
np_<NINE_PATCH_NAME>.xml - for nine-patch XML file
layer_<LAYER_LIST_NAME>.xml - for layer list
selector_<STATE_LIST_NAME>.xml - for state list
anim_<DRAWABLE_ANIMATION_NAME>.xml - for drawable animation
level_<LEVEL_LIST_NAME>.xml - for level list
trans_<TRANSITION_DRAWABLE_NAME>.xml - for transition drawable
inset_<INSET_DRAWABLE_NAME>.xml - for inset drawable
clip_<CLIP_DRAWABLE_NAME>.xml - for clip drawable
scale_<SCALE_DRAWABLE_NAME>.xml - for scale drawable
shape_<SHAPE_DRAWABLE_NAME>.xml - for shape drawable
XML Files (res/layout)
activity_<ACTIVITY_NAME>.xml - for activity
dialog_<DIALOG_NAME>.xml - for dialog
list_item_<LIST_NAME>.xml - for list item in ListView
grid_item_<GRID_NAME>.xml - for grid item in GridView
fragment_<FRAGMENT_NAME>.xml - for fragment
layout_<LAYOUT_NAME>.xml - for re-useable layout
merge_<MERGE_NAME>.xml - for <merge> Tag only
widget_<WIDGET_NAME>.xml - for custom view
appwidget_<APPWIDGET_NAME>.xml - for app widget
XML Files (res/menu)
<MENU_NAME>.xml - for option menu
contextual_<MENU_NAME>.xml - for contextual menu
popup_<MENU_NAME>.xml - for popup menu
XML Files (res/values)
values/[Link]
<color
name="<THEME_NAME>_<COLOR_NAME>"><COLOR_VALUE></color>
For example:
<color name=”holo_blue_dark”>#ff0099cc</color>
<color name=”material_blue_500”>#5677fc</color>
If the color is not in the theme:
<color name="<COLOR_NAME>"><COLOR_VALUE></color>
values/[Link]
<string name="title_<TITLE_NAME>"><TITLE_VALUE></string> - for
ActionBar title
<string
name="action_<ACTION_BUTTON_TEXT>"><TEXT_VALUE></string> - for
ActionBar button text
<string name="tab_<ACTION_TAB_TEXT>"><TEXT_VALUE></string> -
for [Link] text
<string name="btn_<BUTTON_TEXT>"><TEXT_VALUE></string>- for
button
<string name="empty_<VIEW_NAME>"><EMPTY_VALUE></string> - for
empty view
<string name="hint_<EDITTEXT_NAME>"><HINT_VALUE></string>-
for the hint of EditText/AutoCompleteTextView
<string name="label_<TEXTVIEW_NAME>"><TEXT_VALUE></string>-
for static TextView
<string name="toast_<TOAST_NAME>"><TOAST_VALUE></string> - for
toast
<string
name="dialog_title_<DIALOG_NAME>"><TITLE_VALUE></string>- for
dialog
<string
name="dialog_msg_<DIALOG_NAME>"><MSG_VALUE></string> - for
dialog
<string
name="dialog_action_<ACTION_NAME>"><ACTION_NAME></string> -
for dialog button
<string name="msg_<MESSAGE_NAME>"><MSG_VALUE></string> - for
Log or some other stuff
<string
name="contextual_<MENU_ITEM_NAME>"><TEXT_VALUE></string>- for
contextual menu item
<string name="popup_<MENU_ITEM_NAME>"><TEXT_VALUE></string>
- for popup menu item
values/string_arrays.xml
<string-array name="<ARRAY_NAME>_array">
values/[Link]
<plurals name="<PLURALS_NAME>">
XML Files (res/xml)
appwidget_<APPWIDGET_NAME> - for app widget provider
Fuente:
[Link]