Android resource naming code sharing _android

Source: Internet
Author: User
Android resource naming code
In recent months, a lot of work has been done on Android resources. The specification of resource naming is necessary for complex applications. In addition to developers, UI designers (or graph-related people) also need to be very clear about where resources are used, so that communication is straightforward. The disadvantage is that the resource name is longer, but it is worth it in terms of overall value.
The name template is: abbreviation _ Main Interface _ function part
(i) Abbreviation:
IC----------------------icon
BG---------------------Background
Di----------------------Divider
SL-----------------------Selector
CL-----------------------Color
BT----------------------button
IC is mainly used in app icon
BG is primarily used for layout and sub layout backgrounds
Di is mainly used for dividing lines, including not only divider in ListView, but also lines in normal layouts.
SL is mainly used in a view of a variety of States, including not only the selector in the ListView, but also the selector of the button
CL is primarily used for color values
BT is mainly used for the expression of the button, sometimes we will hesitate between IC and BT, a simple distinction is a functional view, if a view is performed on the back or confirm or Cancel function, the name should be used BT
(ii) Main interface:
The main function page, the main activity of app. For browser, for example, Browseractivity,bookmarkactivity,settingactivity,aboutactivity.
(iii) Functional components:
That is, each main interface corresponding function area, take browseractivity as an example, contains the function part: 1,titlebar,2,speedial 3,toolbar,4,menu and so on
Note here that the division of functionality is distinguished by the characteristics of the content displayed in an interface. For example, although menu is controlled by toolbar, it is not subdivided under toolbar.
(iv) Suffix name
Unit--------------------------when using XML Tilemode to match a picture, the element picture uses the suffix
Nor---------------------------the state of the picture, representing the normal state
HL-----------------------------The state of the picture, representing the highlight state
Press-------------------------the state of the picture, representing the pressed state
Select----------------------the state of the picture, representing its view being selected
Unselect-------------------The state of the picture, representing that the view it occupies is not selected
(v) Other
1, for function, relative state, such as open full screen and close full screen. Then the corresponding picture should be _fullscreen and _unfullscreen. In this way, neat and unified, you just need to remember the name of a state.
2, the name of the ID in the XML, the proposal is directly based on the meaning of the name, do not need to use the above complex positioning, because Findviewbyid only in a specified layout find.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.