From 9b825aa0eec5f143cec4c3cfeff97ba8d3d9d093 Mon Sep 17 00:00:00 2001
From: Scott Main
my_image.png is referenced as my_image).
Note: Image resources placed in res/drawable/ may be
+automatically optimized with lossless image compression by the
+aapt tool. For example, a true-color PNG that does
+not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This
+will result in an image of equal quality but which requires less memory. So be aware that the
+image binaries placed in this directory can change during the build. If you plan on reading
+an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/
+folder instead, where they will not be optimized.
The following code snippet demonstrates how to build an {@link android.widget.ImageView} that uses an image from drawable resources and add it to the layout.
@@ -90,7 +99,7 @@ Resources res = mContext.getResources(); Drawable myImage = res.getDrawable(R.drawable.my_image); -Caution: Each unique resource in your project can maintain only one +
Note: Each unique resource in your project can maintain only one state, no matter how many different objects you may instantiate for it. For example, if you instantiate two Drawable objects from the same image resource, then change a property (such as the alpha) for one of the Drawables, then it will also affect the other. So when dealing with multiple instances of an image resource, diff --git a/docs/html/guide/topics/resources/resources-i18n.jd b/docs/html/guide/topics/resources/resources-i18n.jd index b1da4cd6584de..4bbb44ac5e5a2 100644 --- a/docs/html/guide/topics/resources/resources-i18n.jd +++ b/docs/html/guide/topics/resources/resources-i18n.jd @@ -111,21 +111,30 @@ the containing file.
res/drawable/.png, .9.png, .jpg files that are compiled into the following Drawable resource subtypes:
-To get a resource of this type, use Resource.getDrawable(id)
-
To get a resource of this type, use mContext.getResources().getDrawable(R.drawable.imageId)
Note: Image resources placed in here may
+ be automatically optimized with lossless image compression by the
+ aapt tool. For example, a true-color PNG
+ that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette.
+ This will result in an image of equal quality but which requires less memory. So be aware that the
+ image binaries placed in this directory can change during the build. If you plan on reading
+ an image as a bit stream in order to convert it to a bitmap, put your images in the
+ res/raw/ folder instead, where they will not be optimized.
res/layout/res/values/XML files that can be compiled into many kinds of resource.
-Note: unlike the other res/ folders, this one +
Note: Unlike the other res/ folders, this one can hold any number of files that hold descriptions of resources to create rather than the resources themselves. The XML element types control where these resources are placed under the R class.