FileDocCategorySizeDatePackage
DrawableCompat.javaAPI DocAndroid 5.1 API8490Thu Mar 12 22:22:56 GMT 2015android.support.v4.graphics.drawable

DrawableCompat

public class DrawableCompat extends Object
Helper for accessing features in {@link android.graphics.drawable.Drawable} introduced after API level 4 in a backwards compatible fashion.

Fields Summary
static final DrawableImpl
IMPL
Select the correct implementation to use for the current platform.
Constructors Summary
Methods Summary
public static booleanisAutoMirrored(android.graphics.drawable.Drawable drawable)
Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left. See {@link android.util.LayoutDirection}.

If running on a pre-{@link android.os.Build.VERSION_CODES#KITKAT} device this method returns false.

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

        return IMPL.isAutoMirrored(drawable);
    
public static voidjumpToCurrentState(android.graphics.drawable.Drawable drawable)
Call {@link Drawable#jumpToCurrentState() Drawable.jumpToCurrentState()}.

If running on a pre-{@link android.os.Build.VERSION_CODES#HONEYCOMB} device this method does nothing.

param
drawable The Drawable against which to invoke the method.

        final int version = android.os.Build.VERSION.SDK_INT;
        if (version >= 21) {
            IMPL = new LDrawableImpl();
        } else if (version >= 19) {
            IMPL = new KitKatDrawableImpl();
        } else if (version >= 11) {
            IMPL = new HoneycombDrawableImpl();
        } else {
            IMPL = new BaseDrawableImpl();
        }
    
        IMPL.jumpToCurrentState(drawable);
    
public static voidsetAutoMirrored(android.graphics.drawable.Drawable drawable, boolean mirrored)
Set whether this Drawable is automatically mirrored when its layout direction is RTL (right-to left). See {@link android.util.LayoutDirection}.

If running on a pre-{@link android.os.Build.VERSION_CODES#KITKAT} device this method does nothing.

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

        IMPL.setAutoMirrored(drawable, mirrored);
    
public static voidsetHotspot(android.graphics.drawable.Drawable drawable, float x, float y)
Specifies the hotspot's location within the drawable.

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

        IMPL.setHotspot(drawable, x, y);
    
public static voidsetHotspotBounds(android.graphics.drawable.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.

param
drawable The Drawable against which to invoke the method.

        IMPL.setHotspotBounds(drawable, left, top, right, bottom);
    
public static voidsetTint(android.graphics.drawable.Drawable drawable, int tint)
Specifies a tint for {@code drawable}.

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

        IMPL.setTint(drawable, tint);
    
public static voidsetTintList(android.graphics.drawable.Drawable drawable, android.content.res.ColorStateList tint)
Specifies a tint for {@code drawable} as a color state list.

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

        IMPL.setTintList(drawable, tint);
    
public static voidsetTintMode(android.graphics.drawable.Drawable drawable, PorterDuff.Mode tintMode)
Specifies a tint blending mode for {@code drawable}.

param
drawable The Drawable against which to invoke the method.
param
tintMode Color state list to use for tinting this drawable, or null to clear the tint
param
tintMode A Porter-Duff blending mode

        IMPL.setTintMode(drawable, tintMode);