@act262
2017-03-18T12:25:33.000000Z
字数 1274
阅读 1156
android-guidelines-cn
未分类
Android命名规范
Drawable文件命名(.9图、自定义drawable、无dip图)
Asset Type |
Prefix |
Example |
Action bar |
ab_ |
ab_stacked.9.png |
Button |
btn_ |
btn_send_pressed.9.png |
Dialog |
dialog_ |
dialog_top.9.png |
Divider |
divider_ |
divider_horizontal.9.png |
Icon |
ic_ |
ic_star.png |
Menu |
menu_ |
menu_submenu_bg.9.png |
Notification |
notification_ |
notification_bg.9.png |
Tabs |
tab_ |
tab_pressed.9.png |
Drawable图片资源命名
Asset Type |
Prefix |
Example |
Icons |
ic_ |
ic_star.png |
Launcher icons |
ic_launcher |
ic_launcher_calendar.png |
Menu icons and Action Bar icons |
ic_menu |
ic_menu_archive.png |
Status bar icons |
ic_stat_notify |
ic_stat_notify_msg.png |
Tab icons |
ic_tab |
ic_tab_recent.png |
Dialog icons |
ic_dialog |
ic_dialog_info.png |
多状态资源命名
State |
Suffix |
Example |
Normal |
_normal |
btn_order_normal.9.png |
Pressed |
_pressed |
btn_order_pressed.9.png |
Focused |
_focused |
btn_order_focused.9.png |
Disabled |
_disabled |
btn_order_disabled.9.png |
Selected |
_selected |
btn_order_selected.9.png |
布局文件命名
Component |
Class Name |
Layout Name |
Activity |
UserProfileActivity |
activity_user_profile.xml |
Fragment |
SignUpFragment |
fragment_sign_up.xml |
Dialog |
ChangePasswordDialog |
dialog_change_password.xml |
AdapterView item |
|
item_person.xml |
Partial layout |
|
partial_stats_bar.xml |
ViewStub |
|
inflate_xx.xml |
include |
|
include_xx.xml |
merge |
|
merge_xx.xml |
组件id命名
Element |
Prefix |
简写 |
TextView |
text_ |
tv_ |
ImageView |
image_ |
iv_ |
Button |
button_ |
btn_ |
Menu |
menu_ |
menu_ |
LinearLayout |
linear_ |
ll_ |
RelativeLayout |
|
rl_ |
FrameLayout |
|
fl_ |