1. The resource file should be prefixed with the module
2. layout file naming method
The layout of the Activity begins with module_activity
Fragment's layout begins with Module_fragment
Dialog's layout begins with Module_dialog
The include layout starts with Module_include
The row layout of the ListView starts with Module_list_item
Recyclerview's item layout starts with Module_recycle_item
The GridView line layout starts with Module_grid_item
3. drawable resource names are named in lowercase words + underscores, and are stored in different drawable directories according to different resolutions, it is recommended to use only one set, such as drawable-xhdpi. The following rules apply:
Module Name _ Business Function Description _ Control Description _ control state qualifier
Module_login_btn_pressed,module_tabs_icon_home_normal
4. Anim resource names are named in lowercase words + underscores, using the following rules:
Module Name _ logical name _[Direction | serial number]
Tween Animation resources: As far as possible with the general name of the animation, such as Module_fade_in, Module_fade_out, module_push_down_in (animation + direction);
Frame Animation resource: Name + serial number as module + function as possible. such as: module_loading_grey_001
5, the color resource uses #AARRGGBB format, writes the Module_colors.xml file, the naming format uses the following rule:
Module Name _ Logical name _ Color
<color name = "Module_btn_bg_color" > #33b5e5e5 </color>
6. Dimen resources are named in lowercase words + underscores, written in module_dimens.xml files, using the following rules:
Module Name _ Description information
<dimen name= "Module_horizontal_line_height" >1dp</dimen>
7. Style resource is named by lowercase word + underscore, written in Module_styles.xml file, using the following rules:
The name of the parent style. Current style name such as:
<style name= "Parenttheme.thisactivitytheme" >
...
</style>
8. String resource file or text used to write characters need to be all written in the Module_strings.xml file, strings are named in lowercase words + underscores, using the following rules:
Module Name _ Logical name
such as: Moudule_login_tips,module_homepage_notice_desc
9. The ID resource is named in principle by the Hump method, and the resource ID of the view component needs to be prefixed with the view abbreviation. Common abbreviations are as follows:
| Control |
Abbreviation |
| LinearLayout |
ll |
| Relativelayout |
Rl |
| Constraintlayout |
Cl |
| Listview |
Lv |
| Scollview |
Sv |
| TextView |
Tv |
| Button |
Btn |
| ImageView |
iv |
| CheckBox |
Cb |
| RadioButton |
Rb |
| EditText |
Et |
The abbreviations for other controls are recommended to use lowercase letters and split with underscores,
For example: ProgressBar corresponding abbreviation for Progress_bar DatePicker corresponds to the abbreviation for Date_picker
10, large-resolution picture (single-dimensional more than 1000) large-resolution picture is recommended to be unified in the XXHDPI directory management, otherwise it will result in memory multiplication increase.
Description: To support a wide variety of screen sizes and densities, Android provides different resource catalogs for various screens to fit. Provides different bitmap-drawing objects for different screen densities, which can be used for density-specific resource configuration qualifiers (detailed below) including ldpi (Low), MDPI (Medium), hdpi (High), xhdpi (superelevation), xxhdpi (ultra-high), and xxxhdpi (ultra-ultra-high).
For example, a bitmap for a high-density screen should use drawable-hdpi/. Depending on the current device screen size and density, will be looking for the most matching resources, if the high-resolution images into the low-density directory, will cause low-end machine loaded large picture resources, may cause OOM, but also a waste of resources, there is no need to use large-scale image on the low-end machine.
Example: Place the 144*144 application icon png file in the DRAWABLE-XXHDPI directory counter example: Place the 144*144 app icon png file in the DRAWABLE-MHDPI directory
Extension reference: HTTPS://DEVELOPER.ANDROID.COM/GUIDE/PRACTICES/SCREENS_SUPPORT.HTML?HL=ZH-CN
Android resource file naming and use