- Non-public, non-static field names start with m.
- Static field names start with s.
- Other fields start with a lower case letter.
- Public static final fields (constants) are
ALL_CAPS_WITH_UNDERSCORES.
For example:
public class MyClass {
public static final int SOME_CONSTANT = 42;
public int publicField;
private static MyClass sSingleton;
int mPackagePrivate;
private int mPrivate;
protected int mProtected;
}No more than 120 characters.
If-statement body may be written in a single line without braces ({}), if it is short:
// ...
if (!mInstance) createInstance();
// ...4 spaces or one Tab.
Use the prefix which describes the icon type.
-
Icons
- Prefix:
ic_ - Example:
ic_star.png
- Prefix:
-
Launcher icons
- Prefix:
ic_launcher_ - Example:
ic_launcher_calendar.png - If there is only one launcher icon, you can simply name it
icon.png
- Prefix:
-
Menu icons
- Prefix:
ic_menu_ - Example:
ic_menu_archive.png
- Prefix:
-
Status bar icons
- Prefix:
ic_stat_sys_oric_stat_notify_ - Example:
ic_stat_notify_msg.png
- Prefix:
-
Tab icons
- Prefix:
ic_tab_ - Example:
ic_tab_recent.png - Add state name if needed:
pressed,default,selected(e.g.ic_tab_recent_pressed.png)
- Prefix:
-
Dialog icon
- Prefix:
ic_dialog_ - Example:
ic_dialog_info.png
- Prefix:
Example for button called "name":
bt_name_default.pngfor default statebt_name_pressed.pngfor pressed state
Put XML (that defines the animation) to the res/drawable/bt_name.xml file.
dialog_name.xml
- Background:
bg_name.png - Image for
ImageView:im_name.png - Animations:
- keep animation definition files in
res/drawablefolder. - Buttons:
bt_name_anim.png - Activity:
anim_name_of_activity_name_of_animation.png
- keep animation definition files in
If there are lot of animations used in the app, put those in a res/anim folder.
Example:
android:id="@+id/rl_top_panel"
which means the element name is "top panel", and its type is RelativeLayout.
In all other cases follow: