Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save NileshJarad/b8b133f60ef31209cb51aa82428b80a8 to your computer and use it in GitHub Desktop.
Save NileshJarad/b8b133f60ef31209cb51aa82428b80a8 to your computer and use it in GitHub Desktop.
Android coding & naming guidelines

1. Project guidelines

1.1 Project architecture

This project follows the MVP architecture .

For more info Model-View-Presenter.

1.2 File Naming

1.2.1 Class file naming

Class names should be in UpperCamelCase.

For class that extends Android component should end with name of component. eg. UserBasicInfoActivity, AadhaarDetailsFragment, ChangePasswordDialog, UserListAdapter

1.2.2 Layout files naming

Layout file names are written in lowercase_underscore.

Layout files should match the name of the Android components that they are intended for but moving the top level component name to the beginning. For example, if we are creating a layout for the SignInActivity, the name of the layout file should be activity_sign_in.xml.

Component Class Name Layout Name
Activity UserBasicInfoActivity activity_user_basic_info.xml
Fragment AadhaarDetailsFragment fragment_aadhaar_detials.xml
Dialog ChangePasswordDialog dialog_change_password.xml
AdapterView item --- item_person.xml
Partial layout --- partial_stats_bar.xml

1.2.2.1 ID naming xml

ID names in xml are written in lowercase_underscore. Id's for view should start with view name . e.g button_login, et_user_name,

View id name
Button button_login
EditText et_user_name
RecyclerView rv_users
TextInputLayout til_user_name
RadioButton rb_male
RadioGroup rg_gender
TextView tv_header

1.2.2.2 ID naming java

ID names are written in camel case. Id's for view should start with view name . e.g buttonLogin, etUserName,

View id name
Button buttonLogin
EditText etUserName
RecyclerView rv_users
TextInputLayout tilUserName
RadioButton rbMale
RadioGroup rgGender
TextView tvHeader

1.2.2 Values resource naming

Values resource should start with component name. e.g colorWhite, dimesButtonWidth styleGlobalButton

Component key name
color.xml colorScreenBackground
style.xml styleGlobalButton
dimens.xml dimensLoginButtonWidth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment