ShapeDrawable resources are stored in the resvalues directory as explained

Shapedrawable resources are stored in the resvalues

This preview shows page 63 - 69 out of 112 pages.

ShapeDrawable resources are stored in the res/values directory, as explained previously. Here’s a simple ShapeDrawable described in the file res/drawable/red_oval.xml : <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android= "" android:shape="oval"> <solid android:color="#f00"/> </shape>
Image of page 63

Subscribe to view the full document.

Using Simple Drawable Resources Programmatically Drawable resources defined with <drawable> are simply rectangles of a given color, which is represented by the Drawable subclass ColorDrawable . The following code retrieves a ColorDrawable resource called redDrawable : ColorDrawable myDraw = (ColorDrawable) getResources() .getDrawable(R.drawable.redDrawable);
Image of page 64
Working with Images Supported Image Format Description Required Extension Portable Network Graphics (PNG) Preferred format (lossless) .png Nine-Patch Stretchable Graphics Preferred format (lossless) .9.png Joint Photographic Experts Group (JPEG) Acceptable format (lossy) .jpeg , .jpg Graphics Interchange Format (GIF) Discouraged format .gif WebP (WEBP) Android 4.0+ .webp Applications often include visual elements such as icons and graphics. Android supports several image formats that can be directly included as resources for your application. These image formats are shown in this table.
Image of page 65

Subscribe to view the full document.