Android 开发规范

2018-10-20  本文已影响17人  cy_why

此规范遵循《阿里巴巴JAVA开发手册》

1.资源文件需带模块前缀
module_login_btn_pressed,module_tabs_icon_home_normal
<color name="module_btn_bg_color">#33b5e5e5</color>
<dimen name="dp_1">1dp</dimen>
<dimen name="sp_1">1sp</dimen>
<style name="ParentTheme.ThisActivityTheme">
 …
</style>
moudule_login_tips,module_homepage_notice_desc
2.Layout文件的命名方式
Activity的layout:以module_activity开头
Fragment的layout:以module_fragment开头
Dialog的layout:以module_dialog开头
include的layout:以module_include开头
ListView/RecyclerView/GridView的layout:以module_item开头
3.ID的命名方式

Id 资源原则上以驼峰法命名,View 组件的资源 id 需要以 View 的缩写作为
前缀。常用缩写表如下:

控件 缩写
LinearLayout ll
RelativeLayout rl
ConstraintLayout cl
ListView lv
ScrollView sc
TextView tv
Button btn
ImageView iv
CheckBox cb
RadioButton rb
EditText et

其它控件的缩写推荐使用小写字母并以驼峰法命名,例如:
ProgressBar 对应的缩写为 progressBar
DatePicker 对应的缩写为 datePicker

上一篇下一篇

猜你喜欢

热点阅读