GithubHelp home page GithubHelp logo

androidnamingconvention's Introduction

Naming Convention for Android Development

Package Structure

See this Package by feature, not layer

Naming Convention for Classes

  • <PRODUCT_NAME>Application.java - for Application class
  • <NAME>Activity.java - for activity class
  • <NAME>Adapter.java - for adapter class
  • <NAME>Fragment.java - for fragment class
  • <NAME>.java - for model class
  • <NAME>Provider.java - for content provider class
  • <NAME>Service.java - for service class
  • <NAME>Receiver.java - for broadcast receiver class
  • <NAME>Utils.java - 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 - TabHost.TabSpec
  • 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/colors.xml

    • <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/strings.xml

    • <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 ActionBar.Tab 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/plurals.xml

    <plurals name="<PLURALS_NAME>">

XML Files (res/xml)

  • appwidget_<APPWIDGET_NAME> - for app widget provider

androidnamingconvention's People

Contributors

treycai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.