diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:23 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:23 -0800 |
commit | b798689749c64baba81f02e10cf2157c747d6b46 (patch) | |
tree | da394a395ddb1a6cf69193314846b03fe47a397e /graphics | |
parent | f013e1afd1e68af5e3b868c26a653bbfb39538f8 (diff) | |
download | frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.zip frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.tar.gz frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.tar.bz2 |
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'graphics')
12 files changed, 201 insertions, 30 deletions
diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java index cd78043..c6b772e 100644 --- a/graphics/java/android/graphics/drawable/AnimationDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java @@ -28,17 +28,18 @@ import android.util.AttributeSet; /** * - * An object used to define frame-by-frame animations that can be used as a View object's - * background. - * <p>Each frame in a frame-by-frame animation is a drawable - * <a href="{@docRoot}devel/resources-i18n.html">resource</a>. + * An object used to create frame-by-frame animations, defined by a series of Drawable objects, + * which can be used as a View object's background. + * <p> * The simplest way to create a frame-by-frame animation is to define the animation in an XML - * file in the drawable/ folder, set it as the background to a View object, then call - * AnimationDrawable.run() to start the animation, as shown here. More details about the - * format of the animation XML file are given in - * <a href="{@docRoot}reference/available-resources.html#animationdrawable">Frame by Frame - * Animation</a>. - * spin_animation.xml file in res/drawable/ folder:</p> + * file, placed in the res/drawable/ folder, and set it as the background to a View object. Then, call + * {@link #run()} to start the animation. + * <p> + * An AnimationDrawable defined in XML consists of a single <code><animation-list></code> element, + * and a series of nested <code><item></code> tags. Each item defines a frame of the animation. + * See the example below. + * </p> + * <p>spin_animation.xml file in res/drawable/ folder:</p> * <pre><!-- Animation frames are wheel0.png -- wheel5.png files inside the * res/drawable/ folder --> * <animation-list android:id="selected" android:oneshot="false"> @@ -51,7 +52,8 @@ import android.util.AttributeSet; * </animation-list></pre> * * <p>Here is the code to load and play this animation.</p> - * <pre>// Load the ImageView that will host the animation and + * <pre> + * // Load the ImageView that will host the animation and * // set its background to our AnimationDrawable XML resource. * ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image); * img.setBackgroundResource(R.drawable.spin_animation); @@ -62,6 +64,12 @@ import android.util.AttributeSet; * // Start the animation (looped playback by default). * frameAnimation.start() * </pre> + * + * @attr ref android.R.styleable#AnimationDrawable_visible + * @attr ref android.R.styleable#AnimationDrawable_variablePadding + * @attr ref android.R.styleable#AnimationDrawable_oneshot + * @attr ref android.R.styleable#AnimationDrawableItem_duration + * @attr ref android.R.styleable#AnimationDrawableItem_drawable */ public class AnimationDrawable extends DrawableContainer implements Runnable { private final AnimationState mAnimationState; diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index a838c5f..7f3df9a 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -35,6 +35,24 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; +/** + * A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a + * BitmapDrawable from a file path, an input stream, through XML inflation, or from + * a {@link android.graphics.Bitmap} object. + * <p>It can be defined in an XML file with the <code><bitmap></code> element.</p> + * <p> + * Also see the {@link android.graphics.Bitmap} class, which handles the management and + * transformation of raw bitmap graphics, and should be used when drawing to a + * {@link android.graphics.Canvas}. + * </p> + * + * @attr ref android.R.styleable#BitmapDrawable_src + * @attr ref android.R.styleable#BitmapDrawable_antialias + * @attr ref android.R.styleable#BitmapDrawable_filter + * @attr ref android.R.styleable#BitmapDrawable_dither + * @attr ref android.R.styleable#BitmapDrawable_gravity + * @attr ref android.R.styleable#BitmapDrawable_tileMode + */ public class BitmapDrawable extends Drawable { private static final int DEFAULT_PAINT_FLAGS = Paint.FILTER_BITMAP_FLAG; diff --git a/graphics/java/android/graphics/drawable/ClipDrawable.java b/graphics/java/android/graphics/drawable/ClipDrawable.java index 86c0747..6029388 100644 --- a/graphics/java/android/graphics/drawable/ClipDrawable.java +++ b/graphics/java/android/graphics/drawable/ClipDrawable.java @@ -29,11 +29,17 @@ import android.util.Log; import java.io.IOException; /** - * A drawable that clips another drawable based on this drawable's current - * level value. You can control how much the child drawable gets clipped in width + * A Drawable that clips another Drawable based on this Drawable's current + * level value. You can control how much the child Drawable gets clipped in width * and height based on the level, as well as a gravity to control where it is * placed in its overall container. Most often used to implement things like * progress bars. + * + * <p>It can be defined in an XML file with the <code><clip></code> element.</p> + * + * @attr ref android.R.styleable#ClipDrawable_clipOrientation + * @attr ref android.R.styleable#ClipDrawable_gravity + * @attr ref android.R.styleable#ClipDrawable_drawable */ public class ClipDrawable extends Drawable implements Drawable.Callback { private ClipState mClipState; diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java index bebb461..226cc04 100644 --- a/graphics/java/android/graphics/drawable/ColorDrawable.java +++ b/graphics/java/android/graphics/drawable/ColorDrawable.java @@ -26,10 +26,14 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; /** - * A ColorDrawable is a specialized drawable that fills the Canvas with a specified color, - * and with respect to the clip region. Note that a ColorDrawable ignores the ColorFilter. + * A specialized Drawable that fills the Canvas with a specified color, + * with respect to the clip region. Note that a ColorDrawable ignores the ColorFilter. * It also ignores the Bounds, meaning it will draw everywhere in the current clip, * even if setBounds(...) was called with a smaller area. + * + * <p>It can be defined in an XML file with the <code><color></code> element.</p> + * + * @attr ref android.R.styleable#ColorDrawable_color */ public class ColorDrawable extends Drawable { private ColorState mState; diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index ab3b23d..cdfca1b 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -40,9 +40,35 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; /** - * A simple color gradient for buttons, backgrounds, etc. See - * <a href="{@docRoot}reference/available-resources.html#gradientdrawable">Gradient</a> - * in the Resources topic to learn how to specify this type as an XML resource. + * A Drawable with a color gradient for buttons, backgrounds, etc. + * + * <p>It can be defined in an XML file with the <code><shape></code> element.</p> + * + * @attr ref android.R.styleable#GradientDrawable_visible + * @attr ref android.R.styleable#GradientDrawable_shape + * @attr ref android.R.styleable#GradientDrawable_innerRadiusRatio + * @attr ref android.R.styleable#GradientDrawable_thicknessRatio + * @attr ref android.R.styleable#GradientDrawable_useLevel + * @attr ref android.R.styleable#GradientDrawableSize_width + * @attr ref android.R.styleable#GradientDrawableSize_height + * @attr ref android.R.styleable#GradientDrawableGradient_startColor + * @attr ref android.R.styleable#GradientDrawableGradient_centerColor + * @attr ref android.R.styleable#GradientDrawableGradient_endColor + * @attr ref android.R.styleable#GradientDrawableGradient_useLevel + * @attr ref android.R.styleable#GradientDrawableGradient_angle + * @attr ref android.R.styleable#GradientDrawableGradient_type + * @attr ref android.R.styleable#GradientDrawableGradient_centerX + * @attr ref android.R.styleable#GradientDrawableGradient_centerY + * @attr ref android.R.styleable#GradientDrawableGradient_gradientRadius + * @attr ref android.R.styleable#GradientDrawableSolid_color + * @attr ref android.R.styleable#GradientDrawableStroke_width + * @attr ref android.R.styleable#GradientDrawableStroke_color + * @attr ref android.R.styleable#GradientDrawableStroke_dashWidth + * @attr ref android.R.styleable#GradientDrawableStroke_dashGap + * @attr ref android.R.styleable#GradientDrawablePadding_left + * @attr ref android.R.styleable#GradientDrawablePadding_top + * @attr ref android.R.styleable#GradientDrawablePadding_right + * @attr ref android.R.styleable#GradientDrawablePadding_bottom */ public class GradientDrawable extends Drawable { /** diff --git a/graphics/java/android/graphics/drawable/InsetDrawable.java b/graphics/java/android/graphics/drawable/InsetDrawable.java index fe21692..80b8e96 100644 --- a/graphics/java/android/graphics/drawable/InsetDrawable.java +++ b/graphics/java/android/graphics/drawable/InsetDrawable.java @@ -31,6 +31,15 @@ import java.io.IOException; * A Drawable that insets another Drawable by a specified distance. * This is used when a View needs a background that is smaller than * the View's actual bounds. + * + * <p>It can be defined in an XML file with the <code><inset></code> element.</p> + * + * @attr ref android.R.styleable#InsetDrawable_visible + * @attr ref android.R.styleable#InsetDrawable_drawable + * @attr ref android.R.styleable#InsetDrawable_insetLeft + * @attr ref android.R.styleable#InsetDrawable_insetRight + * @attr ref android.R.styleable#InsetDrawable_insetTop + * @attr ref android.R.styleable#InsetDrawable_insetBottom */ public class InsetDrawable extends Drawable implements Drawable.Callback { diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java index c389eb3..fa5ed0a 100644 --- a/graphics/java/android/graphics/drawable/LayerDrawable.java +++ b/graphics/java/android/graphics/drawable/LayerDrawable.java @@ -27,8 +27,20 @@ import android.view.View; import java.io.IOException; -/** Drawable that manages an array of other drawables. These are drawn in array - order, so the element with the largest index will be drawn on top. +/** + * A Drawable that manages an array of other Drawables. These are drawn in array + * order, so the element with the largest index will be drawn on top. + * <p> + * It can be defined in an XML file with the <code><layer-list></code> element. + * Each Drawable in the layer is defined in a nested <code><item></code>. + * </p> + * + * @attr ref android.R.styleable#LayerDrawableItem_left + * @attr ref android.R.styleable#LayerDrawableItem_top + * @attr ref android.R.styleable#LayerDrawableItem_right + * @attr ref android.R.styleable#LayerDrawableItem_bottom + * @attr ref android.R.styleable#LayerDrawableItem_drawable + * @attr ref android.R.styleable#LayerDrawableItem_id */ public class LayerDrawable extends Drawable implements Drawable.Callback { LayerState mLayerState; diff --git a/graphics/java/android/graphics/drawable/LevelListDrawable.java b/graphics/java/android/graphics/drawable/LevelListDrawable.java index 61f45b3..93dc32c 100644 --- a/graphics/java/android/graphics/drawable/LevelListDrawable.java +++ b/graphics/java/android/graphics/drawable/LevelListDrawable.java @@ -27,13 +27,19 @@ import android.util.AttributeSet; /** * - * A resource that contains a number of alternate images, each assigned a maximum numerical value. + * A resource that manages a number of alternate Drawables, each assigned a maximum numerical value. * Setting the level value of the object with {@link #setLevel(int)} will load the image with the next - * greater or equal value assigned to its max attribute. See <a href="{@docRoot}reference/available-resources.html#levellistdrawable"> - * Level List</a> in the Resources topic to learn how to specify this type as an XML resource. A good example use of + * greater or equal value assigned to its max attribute. + * A good example use of * a LevelListDrawable would be a battery level indicator icon, with different images to indicate the current * battery level. - * + * <p> + * It can be defined in an XML file with the <code><level-list></code> element. + * Each Drawable level is defined in a nested <code><item></code> + * </p> + * @attr ref android.R.styleable#LevelListDrawableItem_minLevel + * @attr ref android.R.styleable#LevelListDrawableItem_maxLevel + * @attr ref android.R.styleable#LevelListDrawableItem_drawable */ public class LevelListDrawable extends DrawableContainer { public LevelListDrawable() diff --git a/graphics/java/android/graphics/drawable/RotateDrawable.java b/graphics/java/android/graphics/drawable/RotateDrawable.java index c2f05ec..3e03ed4 100644 --- a/graphics/java/android/graphics/drawable/RotateDrawable.java +++ b/graphics/java/android/graphics/drawable/RotateDrawable.java @@ -31,9 +31,18 @@ import android.util.Log; import java.io.IOException; /** - * <p>A drawable that can rotate another drawable based on the current level + * <p>A Drawable that can rotate another Drawable based on the current level * value. The start and end angles of rotation can be controlled to map any * circular arc to the level values range.</p> + * + * <p>It can be defined in an XML file with the <code><rotate></code> element.</p> + * + * @attr ref android.R.styleable#RotateDrawable_visible + * @attr ref android.R.styleable#RotateDrawable_fromDegrees + * @attr ref android.R.styleable#RotateDrawable_toDegrees + * @attr ref android.R.styleable#RotateDrawable_pivotX + * @attr ref android.R.styleable#RotateDrawable_pivotY + * @attr ref android.R.styleable#RotateDrawable_drawable */ public class RotateDrawable extends Drawable implements Drawable.Callback { diff --git a/graphics/java/android/graphics/drawable/ScaleDrawable.java b/graphics/java/android/graphics/drawable/ScaleDrawable.java index c39f1fa..c40c8c0 100644 --- a/graphics/java/android/graphics/drawable/ScaleDrawable.java +++ b/graphics/java/android/graphics/drawable/ScaleDrawable.java @@ -29,11 +29,18 @@ import android.util.Log; import java.io.IOException; /** - * A drawable that changes the size of another drawable based on its current - * level value. You can control how much the child drawable changes in width + * A Drawable that changes the size of another Drawable based on its current + * level value. You can control how much the child Drawable changes in width * and height based on the level, as well as a gravity to control where it is * placed in its overall container. Most often used to implement things like * progress bars. + * + * <p>It can be defined in an XML file with the <code><scale></code> element.</p> + * + * @attr ref android.R.styleable#ScaleDrawable_scaleWidth + * @attr ref android.R.styleable#ScaleDrawable_scaleHeight + * @attr ref android.R.styleable#ScaleDrawable_scaleGravity + * @attr ref android.R.styleable#ScaleDrawable_drawable */ public class ScaleDrawable extends Drawable implements Drawable.Callback { private ScaleState mScaleState; diff --git a/graphics/java/android/graphics/drawable/StateListDrawable.java b/graphics/java/android/graphics/drawable/StateListDrawable.java index 17d5a2e..1dc1627 100644 --- a/graphics/java/android/graphics/drawable/StateListDrawable.java +++ b/graphics/java/android/graphics/drawable/StateListDrawable.java @@ -31,6 +31,24 @@ import android.util.StateSet; * Lets you assign a number of graphic images to a single Drawable and swap out the visible item by a string * ID value. * + * <p>It can be defined in an XML file with the <code><selector></code> element. + * Each state Drawable is defined in a nested <code><item></code> element.</p> + * + * @attr ref android.R.styleable#StateListDrawable_visible + * @attr ref android.R.styleable#StateListDrawable_variablePadding + * @attr ref android.R.styleable#StateListDrawable_constantSize + * @attr ref android.R.styleable#DrawableStates_state_focused + * @attr ref android.R.styleable#DrawableStates_state_window_focused + * @attr ref android.R.styleable#DrawableStates_state_enabled + * @attr ref android.R.styleable#DrawableStates_state_checkable + * @attr ref android.R.styleable#DrawableStates_state_checked + * @attr ref android.R.styleable#DrawableStates_state_selected + * @attr ref android.R.styleable#DrawableStates_state_active + * @attr ref android.R.styleable#DrawableStates_state_single + * @attr ref android.R.styleable#DrawableStates_state_first + * @attr ref android.R.styleable#DrawableStates_state_middle + * @attr ref android.R.styleable#DrawableStates_state_last + * @attr ref android.R.styleable#DrawableStates_state_pressed */ public class StateListDrawable extends DrawableContainer { public StateListDrawable() @@ -144,7 +162,45 @@ public class StateListDrawable extends DrawableContainer { StateListState getStateListState() { return mStateListState; } + + /** + * Gets the number of states contained in this drawable. + * + * @return The number of states contained in this drawable. + * @see #getStateSet(int) + * @see #getStateDrawable(int) + * @hide pending API council + */ + public int getStateCount() { + return mStateListState.getChildCount(); + } + /** + * Gets the state set at an index. + * + * @param index The index of the state set. + * @return The state set at the index. + * @see #getStateCount() + * @see #getStateDrawable(int) + * @hide pending API council + */ + public int[] getStateSet(int index) { + return mStateListState.mStateSets[index]; + } + + /** + * Gets the drawable at an index. + * + * @param index The index of the drawable. + * @return The drawable at the index. + * @see #getStateCount() + * @see #getStateSet(int) + * @hide pending API council + */ + public Drawable getStateDrawable(int index) { + return mStateListState.getChildren()[index]; + } + static final class StateListState extends DrawableContainerState { StateListState(StateListState orig, StateListDrawable owner) diff --git a/graphics/java/android/graphics/drawable/TransitionDrawable.java b/graphics/java/android/graphics/drawable/TransitionDrawable.java index e12f4b5..a99d4e5 100644 --- a/graphics/java/android/graphics/drawable/TransitionDrawable.java +++ b/graphics/java/android/graphics/drawable/TransitionDrawable.java @@ -20,9 +20,19 @@ import android.graphics.Canvas; import android.os.SystemClock; /** - * Transition drawables are an extension of LayerDrawables and are intended to cross fade between - * the first and second layers. To start the transition, call {@link #startTransition(int)}. To - * display just the first layer, call {@link #resetTransition()} + * An extension of LayerDrawables that is intended to cross-fade between + * the first and second layer. To start the transition, call {@link #startTransition(int)}. To + * display just the first layer, call {@link #resetTransition()}. + * <p> + * It can be defined in an XML file with the <code><transition></code> element. + * Each Drawable in the transition is defined in a nested <code><item></code>. + * </p> + * @attr ref android.R.styleable#LayerDrawableItem_left + * @attr ref android.R.styleable#LayerDrawableItem_top + * @attr ref android.R.styleable#LayerDrawableItem_right + * @attr ref android.R.styleable#LayerDrawableItem_bottom + * @attr ref android.R.styleable#LayerDrawableItem_drawable + * @attr ref android.R.styleable#LayerDrawableItem_id * */ public class TransitionDrawable extends LayerDrawable implements Drawable.Callback { |