Android APIs
public class

DrawableCompat

extends Object
java.lang.Object
   ↳ android.support.v4.graphics.drawable.DrawableCompat

Class Overview

Helper for accessing features in Drawable introduced after API level 4 in a backwards compatible fashion.

Summary

Public Constructors
DrawableCompat()
Public Methods
static boolean isAutoMirrored(Drawable drawable)
Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left.
static void jumpToCurrentState(Drawable drawable)
static void setAutoMirrored(Drawable drawable, boolean mirrored)
Set whether this Drawable is automatically mirrored when its layout direction is RTL (right-to left).
static void setHotspot(Drawable drawable, float x, float y)
Specifies the hotspot's location within the drawable.
static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom)
Sets the bounds to which the hotspot is constrained, if they should be different from the drawable bounds.
static void setTint(Drawable drawable, int tint)
Specifies a tint for drawable.
static void setTintList(Drawable drawable, ColorStateList tint)
Specifies a tint for drawable as a color state list.
static void setTintMode(Drawable drawable, PorterDuff.Mode tintMode)
Specifies a tint blending mode for drawable.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DrawableCompat ()

Public Methods

public static boolean isAutoMirrored (Drawable drawable)

Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left. See LayoutDirection.

If running on a pre-KITKAT device this method returns false.

Parameters
drawable The Drawable against which to invoke the method.
Returns
  • boolean Returns true if this Drawable will be automatically mirrored.

public static void jumpToCurrentState (Drawable drawable)

Call Drawable.jumpToCurrentState().

If running on a pre-HONEYCOMB device this method does nothing.

Parameters
drawable The Drawable against which to invoke the method.

public static void setAutoMirrored (Drawable drawable, boolean mirrored)

Set whether this Drawable is automatically mirrored when its layout direction is RTL (right-to left). See LayoutDirection.

If running on a pre-KITKAT device this method does nothing.

Parameters
drawable The Drawable against which to invoke the method.
mirrored Set to true if the Drawable should be mirrored, false if not.

public static void setHotspot (Drawable drawable, float x, float y)

Specifies the hotspot's location within the drawable.

Parameters
drawable The Drawable against which to invoke the method.
x The X coordinate of the center of the hotspot
y The Y coordinate of the center of the hotspot

public static void setHotspotBounds (Drawable drawable, int left, int top, int right, int bottom)

Sets the bounds to which the hotspot is constrained, if they should be different from the drawable bounds.

Parameters
drawable The Drawable against which to invoke the method.

public static void setTint (Drawable drawable, int tint)

Specifies a tint for drawable.

Parameters
drawable The Drawable against which to invoke the method.
tint Color to use for tinting this drawable

public static void setTintList (Drawable drawable, ColorStateList tint)

Specifies a tint for drawable as a color state list.

Parameters
drawable The Drawable against which to invoke the method.
tint Color state list to use for tinting this drawable, or null to clear the tint

public static void setTintMode (Drawable drawable, PorterDuff.Mode tintMode)

Specifies a tint blending mode for drawable.

Parameters
drawable The Drawable against which to invoke the method.
tintMode A Porter-Duff blending mode