Skip to content

Commit 2316d62

Browse files
committed
docs: add information about using color resources as drawables
Change-Id: I24d82292b700104294d268894b660bc8b7e5ddb0
1 parent 9bc4039 commit 2316d62

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

docs/html/guide/topics/resources/drawable-resource.jd

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ parent.link=available-resources.html
1212
</div>
1313
</div>
1414

15-
<p>A drawable resource is a general concept for a graphic that you
16-
can retrieve with {@link android.content.res.Resources#getDrawable(int)}
17-
and draw on the screen. There are several different types of drawables:</p>
15+
<p>A drawable resource is a general concept for a graphic that can be drawn to the screen and which
16+
you can retrieve with APIs such as {@link android.content.res.Resources#getDrawable(int)} or apply
17+
to another XML resource with attributes such as {@code android:drawable} and {@code android:icon}.
18+
There are several different types of drawables:</p>
1819
<dl>
1920
<dt><a href="#Bitmap">Bitmap File</a><dt>
2021
<dd>A bitmap graphic file ({@code .png}, {@code .jpg}, or {@code .gif}).
@@ -51,6 +52,12 @@ current level value. Creates a {@link android.graphics.drawable.ScaleDrawable}<
5152
<p>Also see the <a href="animation-resource.html">Animation Resource</a> document for how to
5253
create an {@link android.graphics.drawable.AnimationDrawable}.</p>
5354

55+
<p class="note"><strong>Note:</strong> A <a
56+
href="{@docRoot}guide/topics/resources/more-resources.html#Color">color resource</a> can also be
57+
used as a drawable in XML. For example, when creating a <a href="#StateList">state list
58+
drawable</a>, you can reference a color resource for the {@code android:drawable} attribute ({@code
59+
android:drawable="@color/green"}).</p>
60+
5461

5562

5663

docs/html/guide/topics/resources/more-resources.jd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ boolean screenIsSmall = res.{@link android.content.res.Resources#getBoolean(int)
114114
<h2 id="Color">Color</h2>
115115

116116
<p>A color value defined in XML.
117-
The color is specified with an RGB value and alpha channel. You can use color resource
118-
any place that accepts a hexadecimal color value.</p>
117+
The color is specified with an RGB value and alpha channel. You can use a color resource
118+
any place that accepts a hexadecimal color value. You can also use a color resource when a
119+
drawable resource is expected in XML (for example, {@code android:drawable="@color/green"}).</p>
119120

120121
<p>The value always begins with a pound (#) character and then followed by the
121122
Alpha-Red-Green-Blue information in one of the following formats:</p>

0 commit comments

Comments
 (0)