Android Tips, Techniques and Theory

PART 1: Creating Content with XML with Android Studio (No programming required)

With Simple Recipes

Go Back To TOC


XML

XML (eXtensible Markup Language) defines a set of rules for encoding a document that is both human and machine readable. It is used to define many resources files within Android in which many are created automatically when a new Android project is created in specific directories. Some resources; however, have to be created manually.

Manifests directory:

res/drawable directory:

res/layout directory:

res/menu directory:

res/values directory:

res/xml directory:

res/raw directory:


NOTES:

id attribute

Each component (view) that needs to be referenced by a Java file is required to have an id:

You may also see the syntax without a plus sign (+) that can be used when referring to an existing id with the same name in RelativeLayout container when referring another component for its id.

TIPS: While the Layout Editor (See next topic) automatically creates ids for each component, it is best practice to give those components more descriptive names with the same naming convention for each (e.g., playGameButtonId). Also, it is OK to use the first syntax for everything.