Home | History | Annotate | Download | only in drawable

Lines Matching defs:Drawable

17 package android.graphics.drawable;
64 * A Drawable is a general abstraction for "something that can be drawn." Most
65 * often you will deal with Drawable as the type of resource retrieved for
66 * drawing things to the screen; the Drawable class provides a generic API for
68 * Unlike a {@link android.view.View}, a Drawable does not have any facility to
71 * <p>In addition to simple drawing, Drawable provides a number of generic
76 * Drawable where it is drawn and how large it should be. All Drawables
83 * For example, a Drawable that is intended to be the frame for a button
87 * <li> The {@link #setState} method allows the client to tell the Drawable
92 * continuous controller that can modify the Drawable is displayed, such as
96 * <li> A Drawable can perform animations by calling back to its client
100 * {@link android.view.View#setBackground(Drawable)} and
108 * <li> <b>Bitmap</b>: the simplest Drawable, a PNG or JPEG image.
112 * <li><b>Vector</b>: a drawable defined in an XML file as a set of points,
114 * of drawable can be scaled without loss of display quality.
117 * <li> <b>Layers</b>: a compound drawable, which draws multiple underlying
119 * <li> <b>States</b>: a compound drawable that selects one of a set of
121 * <li> <b>Levels</b>: a compound drawable that selects one of a set of
123 * <li> <b>Scale</b>: a compound drawable with a single child drawable,
131 * All versions of Android allow the Drawable class to be extended and used at
132 * run time in place of framework-provided drawable classes. Starting in
136 * <strong>Note:</strong> Custom drawable classes are only accessible from
140 * At a minimum, custom drawable classes must implement the abstract methods on
141 * Drawable and should override the {@link Drawable#draw(Canvas)} method to
148 * this method, the custom drawable class must be a public top-level
156 * Using <em>drawable</em> as the XML element name and specifying the
161 * &lt;drawable xmlns:android="http://schemas.android.com/apk/res/android"
172 * guide. For information and examples of creating drawable resources (XML or bitmap files that
174 * <a href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>
177 public abstract class Drawable {
215 * Specify a bounding rectangle for the Drawable. This is where the drawable
237 * Specify a bounding rectangle for the Drawable. This is where the drawable
245 * Return a copy of the drawable's bounds in the specified Rect (allocated
249 * @param bounds Rect to receive the drawable's bounds (allocated by the
257 * Return a copy of the drawable's bounds in a new Rect. This returns the
259 * be changed later by the drawable (i.e. it retains no reference to this
262 * @return A copy of the drawable's bounds
270 * Return the drawable's bounds Rect. Note: for efficiency, the returned
271 * object may be the same object stored in the drawable (though this is not
275 * be the same object stored in the drawable.
277 * @return The bounds of the drawable (which may change later, so caller
279 * stored bounds of this drawable.
294 * Return the drawable's dirty bounds Rect. Note: for efficiency, the
295 * returned object may be the same object stored in the drawable (though
298 * By default, this returns the full drawable bounds. Custom drawables may
301 * @return The dirty bounds of this drawable
309 * Set a mask of the configuration parameters for which this drawable
322 * Return a mask of the configuration parameters for which this drawable
339 * Set to true to have the drawable dither its colors when drawn to a
349 * Set to true to have the drawable filter its bitmaps with bilinear
352 * <p>This can improve appearance when bitmaps are rotated. If the drawable
361 * @return whether this drawable filters its bitmaps
369 * Implement this interface if you want to create an animated drawable that
370 * extends {@link android.graphics.drawable.Drawable Drawable}.
371 * Upon retrieving a drawable, use
372 * {@link Drawable#setCallback(android.graphics.drawable.Drawable.Callback)}
373 * to supply your implementation of the interface to the drawable; it uses
378 * Called when the drawable needs to be redrawn. A view at this point
380 * drawable appears).
382 * @param who The drawable that is requesting the update.
384 void invalidateDrawable(@NonNull Drawable who);
387 * A Drawable can call this to schedule the next frame of its
393 * @param who The drawable being scheduled.
398 void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when);
401 * A Drawable can call this to unschedule an action previously
405 * the parameters <var>(what, who)</var> to unschedule the drawable.
407 * @param who The drawable being unscheduled.
410 void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what);
414 * Bind a {@link Callback} object to this Drawable. Required for clients
427 * Drawable.
431 * @see #setCallback(android.graphics.drawable.Drawable.Callback)
439 * Use the current {@link Callback} implementation to have this Drawable
441 * Drawable.
445 * @see #setCallback(android.graphics.drawable.Drawable.Callback)
455 * Use the current {@link Callback} implementation to have this Drawable
457 * Drawable.
472 * Use the current {@link Callback} implementation to have this Drawable
474 * Drawable.
488 * Returns the resolved layout direction for this Drawable.
499 * Set the layout direction for this drawable. Should be a resolved
500 * layout direction, as the Drawable has no capacity to do the resolution on
503 * @param layoutDirection the resolved layout direction for the drawable,
507 * appearance of the drawable to change such that it needs to be
520 * Called when the drawable's resolved layout direction changes.
524 * appearance of the drawable to change such that it needs to be
533 * Specify an alpha value for the drawable. 0 means fully transparent, and
539 * Gets the current alpha value for the drawable. 0 means fully transparent,
541 * Drawable subclasses and the value returned is specific to how that class treats alpha.
564 * Specify an optional color filter for the drawable.
566 * If a Drawable has a ColorFilter, each output pixel of the Drawable's
584 * drawable.
604 * Specifies tint color for this drawable.
606 * A Drawable's drawing content will be blended together with its tint
619 * @param tintColor Color to use for tinting this drawable
628 * Specifies tint color for this drawable as a color state list.
630 * A Drawable's drawing content will be blended together with its tint
639 * @param tint Color state list to use for tinting this drawable, or
647 * Specifies a tint blending mode for this drawable.
649 * Defines how this drawable's tint color should be blended into the drawable
673 * Removes the color filter for this drawable.
680 * Specifies the hotspot's location within the drawable.
689 * different from the drawable bounds.
710 * Whether this drawable requests projection.
719 * Indicates whether this drawable will change its appearance based on
723 * @return True if this drawable changes its appearance based on state,
732 * Indicates whether this drawable has at least one state spec explicitly
735 * <p>Note: A View uses a {@link Drawable} instance as its background and it
741 * for this drawable.
751 * Specify a set of states for the drawable. These are use-case specific,
758 * Drawable to change, then it is responsible for calling
762 * <p>Note: The Drawable holds a reference on to <var>stateSet</var>
769 * of the Drawable to change (hence requiring an invalidate), otherwise
792 * If this Drawable does transition animations between states, ask that
799 * @return The current drawable that will be used by this drawable. For simple drawables, this
800 * is just the drawable itself. For drawables that change state like
801 * {@link StateListDrawable} and {@link LevelListDrawable} this will be the child drawable
804 public @NonNull Drawable getCurrent() {
809 * Specify the level for the drawable. This allows a drawable to vary its
814 * Drawable to change, then it is responsible for calling
821 * of the Drawable to change (hence requiring an invalidate), otherwise
842 * Set whether this Drawable is visible. This generally does not impact
843 * the Drawable's behavior, but is a hint that can be used by some
847 * @param restart You can supply true here to force the drawable to behave
869 * Set whether this Drawable is automatically mirrored when its layout direction is RTL
872 * @param mirrored Set to true if the Drawable should be mirrored, false if not.
878 * Tells if this Drawable will be automatically mirrored when its layout direction is RTL
881 * @return boolean Returns true if this Drawable will be automatically mirrored.
888 * Applies the specified theme to this Drawable and its children.
900 * Return the opacity/transparency of this Drawable. The returned value is
908 * <p>An OPAQUE drawable is one that draws all all content within its bounds, completely
909 * covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing
910 * within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable
911 * is a drawable in any other state, where the drawable will draw some, but not all,
912 * of the content within its bounds and at least some content behind the drawable will
913 * be visible. If the visibility of the drawable's contents cannot be determined, the
916 * <p>Generally a Drawable should be as conservative as possible with the
930 * @return int The opacity class of the Drawable.
969 * Returns a Region representing the part of the Drawable that is completely
971 * which parts of the target will not change when rendering the Drawable.
978 * report, else a Region holding the parts of the Drawable's bounds that
990 * the Drawable to change (that is, it needs to be drawn), else false
1001 * the Drawable to change (that is, it needs to be drawn), else false
1018 * Returns the drawable's intrinsic width.
1020 * Intrinsic width is the width at which the drawable would like to be laid
1021 * out, including any inherent padding. If the drawable has no intrinsic
1031 * Returns the drawable's intrinsic height.
1033 * Intrinsic height is the height at which the drawable would like to be
1034 * laid out, including any inherent padding. If the drawable has no
1044 * Returns the minimum width suggested by this Drawable. If a View uses this
1045 * Drawable as a background, it is suggested that the View use at least this
1049 * @return The minimum width suggested by this Drawable. If this Drawable
1058 * Returns the minimum height suggested by this Drawable. If a View uses this
1059 * Drawable as a background, it is suggested that the View use at least this
1063 * @return The minimum height suggested by this Drawable. If this Drawable
1072 * Return in padding the insets suggested by this Drawable for placing
1073 * content inside the drawable's bounds. Positive values move toward the
1074 * center of the Drawable (set Rect.inset).
1076 * @return true if this drawable actually has a padding, else false. When false is returned,
1085 * Return in insets the layout insets suggested by this Drawable for use with alignment
1095 * Called to get the drawable to populate the Outline that defines its drawing area.
1111 * Make this drawable mutable. This operation cannot be reversed. A mutable
1112 * drawable is guaranteed to not share its state with any other drawable.
1118 * Calling this method on a mutable Drawable will have no effect.
1120 * @return This drawable.
1124 public @NonNull Drawable mutate() {
1129 * Clears the mutated state, allowing this drawable to be cached and
1143 * Create a drawable from an inputstream
1145 public static Drawable createFromStream(InputStream is, String srcName) {
1146 Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, srcName != null ? srcName : "Unknown drawable");
1155 * Create a drawable from an inputstream, using the given resources and
1158 public static Drawable createFromResourceStream(Resources res, TypedValue value,
1160 Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, srcName != null ? srcName : "Unknown drawable");
1169 * Create a drawable from an inputstream, using the given resources and
1172 public static Drawable createFromResourceStream(Resources res, TypedValue value,
1194 opts.inScreenDensity = Drawable.resolveDensity(res, 0);
1211 * Create a drawable from an XML document. For more information on how to
1213 * <a href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>.
1216 public static Drawable createFromXml(@NonNull Resources r, @NonNull XmlPullParser parser)
1222 * Create a drawable from an XML document using an optional {@link Theme}.
1224 * <a href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>.
1227 public static Drawable createFromXml(@NonNull Resources r, @NonNull XmlPullParser parser,
1238 public static Drawable createFromXmlForDensity(@NonNull Resources r,
1254 Drawable drawable = createFromXmlInnerForDensity(r, parser, attrs, density, theme);
1256 if (drawable == null) {
1260 return drawable;
1265 * a tag in an XML document, tries to create a Drawable from that tag.
1266 * Returns null if the tag is not a valid drawable.
1269 public static Drawable createFromXmlInner(@NonNull Resources r, @NonNull XmlPullParser parser,
1275 * Create a drawable from inside an XML document using an optional
1277 * document, tries to create a Drawable from that tag. Returns {@code null}
1278 * if the tag is not a valid drawable.
1281 public static Drawable
1292 static Drawable createFromXmlInnerForDensity(@NonNull Resources r,
1300 * Create a drawable from file path name.
1303 public static Drawable createFromPath(String pathName) {
1322 * Inflate this Drawable from an XML resource. Does not apply a theme.
1332 * Inflate this Drawable from an XML resource optionally styled by a theme.
1333 * This can't be called more than once for each Drawable. Note that framework may have called
1334 * this once to create the Drawable instance from XML resource.
1337 * @param parser XML parser from which to inflate this Drawable
1346 final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.Drawable);
1352 * Inflate a Drawable from an XML resource.
1364 * Sets the source override density for this Drawable. If non-zero, this density is to be used
1374 * This abstract class is used by {@link Drawable}s to store shared constant state and data
1379 * {@link #newDrawable(Resources)} can be used as a factory to create new Drawable instances
1383 * Use {@link Drawable#getConstantState()} to retrieve the ConstantState of a Drawable. Calling
1384 * {@link Drawable#mutate()} on a Drawable should typically create a new ConstantState for that
1385 * Drawable.
1389 * Creates a new Drawable instance from its constant state.
1397 * @return a new drawable object based on this constant state
1400 public abstract @NonNull Drawable newDrawable();
1403 * Creates a new Drawable instance from its constant state using the
1410 * @param res the resources of the context in which the drawable will
1412 * @return a new drawable object based on this constant state
1414 public @NonNull Drawable newDrawable(@Nullable Resources res) {
1419 * Creates a new Drawable instance from its constant state using the
1426 * @param res the resources of the context in which the drawable will
1428 * @param theme the theme of the context in which the drawable will be
1430 * @return a new drawable object based on this constant state
1432 public @NonNull Drawable newDrawable(@Nullable Resources res,
1439 * this drawable (and thus require completely reloading it).
1452 * Return a {@link ConstantState} instance that holds the shared state of this Drawable.
1454 * @return The ConstantState associated to that Drawable.
1456 * @see Drawable#mutate()
1462 private static Drawable drawableFromBitmap(Resources res, Bitmap bm, byte[] np,