ShapeDrawableresources are stored in the res/valuesdirectory, as explained previously.Here’s a simple ShapeDrawabledescribed 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>
Subscribe to view the full document.
Using Simple Drawable Resources ProgrammaticallyDrawable resources defined with <drawable>are simply rectangles of a given color, which is represented by the Drawablesubclass ColorDrawable.The following code retrieves a ColorDrawableresource called redDrawable:ColorDrawable myDraw = (ColorDrawable) getResources().getDrawable(R.drawable.redDrawable);
Working with ImagesSupported Image FormatDescriptionRequired ExtensionPortable Network Graphics (PNG)Preferred format (lossless).pngNine-Patch Stretchable GraphicsPreferred format (lossless).9.pngJoint Photographic Experts Group (JPEG)Acceptable format (lossy).jpeg, .jpgGraphics Interchange Format (GIF)Discouraged format.gifWebP (WEBP)Android 4.0+.webpApplications 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.