-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Adapt naming pattern based on https://github.com/ribot/android-guidelines/blob/master/project_and_code_guidelines.md
1.2.2.2 Layout files
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 | UserProfileActivity |
activity_user_profile.xml |
| Fragment | SignUpFragment |
fragment_sign_up.xml |
| Dialog | ChangePasswordDialog |
dialog_change_password.xml |
| AdapterView item | --- | item_person.xml |
| Partial layout | --- | partial_stats_bar.xml |
A slightly different case is when we are creating a layout that is going to be inflated by an Adapter, e.g to populate a ListView. In this case, the name of the layout should start with item_.
Note that there are cases where these rules will not be possible to apply. For example, when creating layout files that are intended to be part of other layouts. In this case you should use the prefix partial_.