Using shape resources

It's all very fine and well being able to change the size and color of the fonts in a widget, but what about fundamentally changing the way in which that widget is rendered? We've already worked a little bit with XML drawable objects, but there is much more that can be done with them.

The work done so far with the XML drawable structures has been confined to putting default images in widgets designed to have an image. However, all widgets in Android are designed to have images. The background attribute of the View class allows you to pass in any drawable resource, combined with style resources. This becomes a very powerful tool. When a shape resource is loaded in Java code, it's returned as a Drawable object.

The shapes that ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.