Skip to Content

Editing Layouts in Text Mode

Learn how we can use text mode to create and edit layouts with XML.

Up until now, we’ve worked exclusively in the visual editor where Android Studio requires both drags and drops from the developer to build layouts, but there is another way.

In text mode, developers craft layouts faster and with less ambiguity. By taking direct control of each component and its attributes, developers can save time and increase readability for teammates who look at and tweak a common set of layouts (not everyone likes design mode, after all). And while designing entirely in text may seem intimidating, Android Studio provides helpful tips and automated guidance along the way.


  • Many types of resource files exist, and Android Studio helps us create the right one each time.
  • Resource qualifiers help us generate XML files for specific device configurations, e.g. when in landscape, running a specific version of Android, and more.
  • AndroidX is a compatibility library that offers unique features and the latest APIs to versions of Android past & present.
  • ConstraintLayout is available exclusively through AndroidX.
  • Namespaces help avoid attribute conflicts (two versions of the src attribute on a single ImageView, for example).
  • Three common namespaces exist: android, tools, and app.
  • The android namespace belongs to the Android SDK and represents attributes available out-of-the-box.
  • The app namespace allows us to reference attributes defined by external libraries (e.g. AndroidX) and those defined by our application.
  • The tools namespace allows us to define attributes used exclusively for development, the user’s device never sees these attributes.
  • To refer and relate to one another, Views must provide a resource identifier (resource ID).
  • Resource IDs are unique, so we must avoid reusing them across layouts.
  • Editing layouts in text mode is not so scary after all!

Ready to Learn More?

Find the course that's right for you! Explore our catalog or get a recommendation.