The following is excerpted from Alibaba’s Android development manual

Our goals are:

  • Prevent trouble, improve quality awareness, reduce failure rate and maintenance cost;
  • Unified standards to improve collaboration efficiency;
  • The pursuit of excellence craftsman spirit, polishing quality code.
  • [Mandatory] Must be observed, breach of this agreement may cause serious consequences;
  • [Recommendation] Try to comply with the long-term compliance is conducive to the improvement of system stability and cooperation efficiency;
  • Full understanding, guided by technical awareness, is the direction of individual learning, team communication and project cooperation.

Ali Android development specification: Naming and using of resource files Ali Android development specification: Four basic components: UI and layout Ali Android development specification: Process, thread and Message communication ali Android development specification: Ali Android development specification: Bitmap, Drawable and animation Ali Android development specification: security and other

1. [Recommended] Resource files must be prefixed with modules. 2, 【 recommended 】 Layout file naming method.

Activity layout starts with module_activity layout starts with module_fragment Layout starts with module_dialog Dialog layout starts with module_dialog include ListView item layout starts with module_list_item GridView item Layout starts with module_grid_item RecyclerView item layout starts with module_RECYcle_itemCopy the code

3. You are advised to use only one set of resource names, such as drawable-xhdpi, and save the resource names in different drawable directories based on the resolution. The adoption rules are as follows:

Module name _ Service Function Description _ Control Description _ Control status determiners such as module_login_bTN_PRESSED and module_TABs_icon_home_normalCopy the code

4. [Recommended] Anim resource names are lowercase words + underscores (_), using the following rules:

Module name logical name _ _ [direction | serial number] tween animation resources: Use general animators as possible, such as module_FAde_in, module_FAde_OUT, module_PUSH_down_IN (animation + direction); Frame Animation resources: module + function name + sequence number if possible. Such as: module_loading_grey_001Copy the code

5. [Recommended] Use #AARRGGBB for color resources and write them into the module_colors. XML file.

Module name_logical name_color Example: <color name="module_btn_bg_color">#33b5e5e5</color>
Copy the code

6. Dimen resources should be named with lowercase words and underscores (_) and written to the module_dimens. XML file using the following rules:

Module name_Description For example, <dimen name="module_horizontal_line_height">1dp</dimen>
Copy the code

7. 【 Recommended 】 The style resources should be named in lowercase words + underscores and written into the module_styles. XML file, using the following rules:

Parent style name. The current style name is: <style name="ParentTheme.ThisActivityTheme">... </style>Copy the code

8. [Recommended] String resource files or text should be written to the module_strings. XML file, and strings should be named with lowercase words and underscores (_).

Module name_Logical name: moudule_LOGin_TIPS, module_HOMepage_notice_descCopy the code

9. [Recommended] RESOURCE Id In principle, the resource Id of a View component should be prefixed with the abbreviation of View. Common abbreviations are listed below:

controls abbreviations
LinearLayout ll
RelativeLayout rl
ConstraintLayout cl
ListView lv
ScollView sv
TextView tv
Button btn
ImageView iv
CheckBox cb
RadioButton rb
EditText et

For other control abbreviations, use lowercase letters and underscores. For example, ProgressBar is progress_bar and DatePicker is date_picker

10. [Recommendation] Large resolution pictures (single dimension more than 1000) Large resolution pictures are recommended to be managed in xxHDPI directory. Otherwise, the memory usage will increase exponentially. Note: In order to support a variety of screen sizes and densities, Android provides different resource directories for various screens. The configuration qualifiers that provide different bitmap drawable objects for different screen densities that can be used for density-specific resources (detailed below) include LDPI (low), MDPI (middle), HDPI (high), XHDPI (super high), XXHDPI (super super high), and XXXHDPI (super super high). For example, bitmaps for high-density screens should use drawable-hdpi/. According to the current screen size and density of the device, we will find the most matching resource. If we put the high resolution picture into the low density directory, it will cause the low-end computer to load too large picture resources, which may cause OOM, and it is also a waste of resources. There is no need to use the large picture on the low-end computer. Example: Save the PNG file of the 144144 application icon in the drawable-xxhdpi directory. Example: Save the PNG file of the 144144 application icon in the drawable-mhdpi directory. https://developer.android.com/guide/practices/screens_support.html?hl=zh-cn

Ali Android development specification: Naming and using of resource files Ali Android development specification: Four basic components: UI and layout Ali Android development specification: Process, thread and Message communication ali Android development specification: Ali Android development specification: Bitmap, Drawable and animation Ali Android development specification: security and other