Referencing Resources within Resources

You can also use resource references as attribute values in other XML resources.

This is particularly useful for layouts and styles, letting you create specialized variations on themes and localized strings and graphics. It's also a useful way to support different images and spacing for a layout to ensure that it's optimized for different screen sizes and resolutions.

To reference one resource from another use @ notation, as shown in the following snippet.


Android will assume you' re using a resource from the same package, so you only need to fully qualify the package name if you' re using a resource from a different package.

Listing 3-4 shows a layout that uses color, dimension, and string resources.

LISTING 3-4: Using resources in a layout

Available for download on

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=""





<EditText android:id="@+id/myEditText"






Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment