Android Reprint one: Android file naming specification

Source: Internet
Author: User

ref:http://blog.csdn.net/gulianchao/article/details/23391651

(i) Layout naming
1. Contentview Name: activity_ function module. xml
For example: Activity_main.xml, Activity_more.xml
2. Dialog name: Dialog_ description. xml
Example: Dlg_hint.xml
2. Popupwindow Name: ppw_ description. xml
Example: PPW _info.xml

    1. List item naming listitem_ description. xml
      Example: Listitem_city.xml
      4. Contains items: Include_ module. xml
      For example: Include_head.xml, Include_bottom.xml

(ii) Image naming

    1.    静态图片前缀_模块、前缀_模块_描述
      For example: Bg_main.png, Ic_main_search.png
    2.    动态图片前缀_模块_描述_状态、前缀_描述_状态          例如:btn_film_buy_n.png、btn_film_buy_p.png、btn_back_n.png   如果有多种形态如按钮等除外如btn_film_buy.xml(selector)

(c) ID name (to be adjusted?? )
The name of the ID in the XML, it is suggested to be named directly by meaning, without using the above complex positioning, because Findviewbyid only find in a specified layout. or value to establish the unified management of ID files (compatibility is not good)
Original author used: Android: id= "@id/tv_name" Android (id= "at Id/tv_name" Android) : id= "@id/listv" (id= "at id/li STV ") , Android: id=" @id/tv_head_title (id= "at Id/tv_head_title) "
Personal usage: android: id= "@id/tvname" Android (id= "at Id/tvname" Android) : id= "@id/listvname" (id= "at ID/ Listvname ") , Android: id=" @id/tvheadtitle "(id=" at Id/tvheadtitle ") , and then the name and ID names in class remain the same

(iv) string naming
Better not with title, dialog, button and other things related, directly with the same English meaning can be, if the following:
Are you sure
Welcome to use
To cite some bad examples, determine the following

(v) Control naming
Control abbreviation _ Description
For example: Textviewtv_name, Button btn_buy, linearlayoutllyt_body;

(vi) class naming
Function module Activity.class function Module Service.class
such as: Mainactivity.class HuaFuBaoActivity.classAppUpgradeService.class

Resource abbreviation Description

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.