Posted on by & filed under Content - Highlights and Reviews, Mobile Development.

One area that has always been a bit lacking for Android developers is the online documentation at It’s getting better with each new release but is still far from perfect. One area which has left many developers lost is styling. There are now plenty of guides on the Internet discussing styling and theming, but below are the two tips I wish someone had told me when I’d started Android development:

1. ‘?’

The question mark in a style refers to a dynamically defined theme value. In the following example, taken directly from the Android styles.xml file, the value of ‘android:textColor’ refers to the value of the dynamically defined “textColorPrimary” value:

As can be seen from the following excerpt from the android-16 themes.xml file, the exact value of the ‘textColorPrimary’ within ‘TextAppearance’, and hence the default text color throughout the app, will vary depending on the theme applied on your application or activity in the AndroidManifest.xml file:

So if we were to define our own theme and wanted to change the default text colour – we can easily override the above value in order to achieve that throughout all parts of our application that used our custom theme:

2. Read the source code

This is a general tip really, but enough emphasis can’t be placed on how much you will learn by reading the Android source code, which can be downloaded via the SDK Manager. To find the style and theme code, find where you installed the Android SDK and have a look at styles.xml and themes.xml in the /platforms/android-XX/data/res/values/ directory.

Really! You’ll learn more by looking at, studying, and playing about with the Android style and theme source code than any guide can ever teach you! For example, there’s no comprehensive documentation of what styles are available to change, but have a look at the default theme (search for ” in the theme.xml file) and you’ll find out how to style every single widget in Android and lots more. This is the best form of guide and documentation rolled in to one – it’s always going to accurately reflect the live code and every single bit of style information is in there. Only the experience of using it will help you get a deeper knowledge of how it works. So…what are you waiting for?

Safari Books Online has the content you need

Check out these Android books available from Safari Books Online:

Android in Action, Third Edition is a fast-paced book that puts you in the driver’s seat–you’ll master the SDK, build WebKit apps using HTML 5, explore cross-platform graphics with RenderScript, learn to use Native Development Kit, and master important tablet concepts like drag-and-drop, fragments, and the Action Bar, all new in Android 3.
Beginning Android 4 is fresh with details on the latest iteration of the Android platform. Begin at the beginning by installing the tools and compiling a skeleton app. Move through creating layouts, employing widgets, taking user input, and giving back results.
Android in Practice is a treasure trove of Android goodness, with over 90 tested, ready-to-use techniques including complete end-to-end example applications and practical tips for real world mobile application developers. The book dives into important topics like multitasking and services, testing and instrumentation, building and deploying applications, and using alternative languages.
Android UI Fundamentals: Develop and Design walks developers through the different choices available on their way to creating a well-designed application for Android. While building a simple application, Jason works through the basics of Android UI development including layout, event handling, menus and notifications.
Programming Android shows experienced application developers what they need to program for the Android operating system — the core building blocks, how to put those blocks together, and how to build compelling apps that work on a full range of Android devices.
Whether you want to develop a commercial application for mobile devices, or just want to create a mobile mashup for personal use, Android Application Development demonstrates how you can design, build, and test applications for the new mobile market

About this author

Martyn Haigh has been a coder since his dad showed him a BBC Micro at the age of 3. He has a degree in Computer Science, likes clean code and has been programming Android devices for longer than it’s been commercially viable. In his spare time he snowboards, slays monsters and has been the Times Magazine person of the year on three different occasions. Sometimes he writes things on He’d love you to visit.

Tags: android, question mark, Styling, themes.xml,

Comments are closed.