Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 919 Bytes

style_rules_xml.md

File metadata and controls

38 lines (27 loc) · 919 Bytes

## XML style rules

Inspired by Ribot Android guideline

Use self closing tags

When an XML element doesn't have any contents, you must use self closing tags.

This is good:

<TextView
    android:id="@+id/text_view_profile"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

This is bad :

<!-- Don\'t do this! -->
<TextView
    android:id="@+id/text_view_profile"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
</TextView>

Attributes ordering

As a general rule you should try to group similar attributes together. A good way of ordering the most common attributes is:

  • View Id
  • Style
  • Layout width and layout height
  • Other layout attributes, sorted alphabetically
  • Remaining attributes, sorted alphabetically