SoFunction
Updated on 2025-03-11

Android resource naming specifications Share

Android resource naming specifications
In recent months, a lot of related work involving Android resources has been involved. For complex applications, resource naming specifications are necessary. In addition to developers, UI designers (or map-cutting personnel) also need to be very clear about the location of resource use, so that communication will be direct. The disadvantage is that the resource name is longer, but from the perspective of overall value, it is worth it.
The naming template is: abbreviation_main interface_functional part
(I) Abbreviation:
ic ----------------------icon
bg---------------------background
di----------------------divider
sl-----------------------selector
cl-----------------------color
bt----------------------button
I mainly use the icons of the app
bg is mainly used for backgrounds of layout and sub-layout
di is mainly used to divide lines, including not only the divider in Listview, but also the lines in ordinary layouts.
sl is mainly used for a view with multiple states, including not only the selector in Listview, but also the selector of buttons.
cl mainly used for color values
bt is mainly used for button representation. Sometimes we hesitate between ic and bt. A simple distinction is the function view. If a view executes the function of back or confirm or cancel, then bt should be used in the name
(II) Main interface:
The main function page is the main activity of the app. For Browser, such as BrowserActivity, BookmarkActivity, SettingActivity, AboutActivity.
(III) Functional part:
That is, the corresponding functional area of ​​each main interface. Taking BrowserActivity as an example, the functional parts included are: 1, titlebar, 2, speedial 3, toolbar, 4, menu, etc.
It is noted here that the division of functions is distinguished by the content characteristics displayed on a certain interface. For example, although menu is controlled by toolbar, it is not subdivided under toolbar.
(IV) Suffix name
unit------------------------------------------------------------------------------------------------------------------------------
nor------------------------------------------------------------------------------------------------------------------------------
hl-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
press--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
select------------------------------------------------------------------------------------------------------------------------------
unselect-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(V) Others
1. For functions, relative states, such as turning on full screen and turning off full screen. Then the corresponding pictures should be _fullscreen and _unfullscreen. In this way, neatly and unified, you only need to remember the naming of one state.
2. The naming of id in Xml is recommended to directly name it according to the meaning, and there is no need to use the above complicated positioning, because findViewById is only found in a specified layout.