FileDocCategorySizeDatePackage
LayerDrawable.javaAPI DocAndroid 5.1 API35596Thu Mar 12 22:22:30 GMT 2015android.graphics.drawable

LayerDrawable

public class LayerDrawable extends Drawable implements Drawable.Callback
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.

It can be defined in an XML file with the <layer-list> element. Each Drawable in the layer is defined in a nested <item>.

For more information, see the guide to Drawable Resources.

attr
ref android.R.styleable#LayerDrawable_paddingMode
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

Fields Summary
public static final int
PADDING_MODE_NEST
Padding mode used to nest each layer inside the padding of the previous layer.
public static final int
PADDING_MODE_STACK
Padding mode used to stack each layer directly atop the previous layer.
LayerState
mLayerState
private int
mOpacityOverride
private int[]
mPaddingL
private int[]
mPaddingT
private int[]
mPaddingR
private int[]
mPaddingB
private final android.graphics.Rect
mTmpRect
private android.graphics.Rect
mHotspotBounds
private boolean
mMutated
Constructors Summary
public LayerDrawable(Drawable[] layers)
Create a new layer drawable with the list of specified layers.

param
layers A list of drawables to use as layers in this new drawable.


                                  
       
        this(layers, null);
    
LayerDrawable(Drawable[] layers, LayerState state)
Create a new layer drawable with the specified list of layers and the specified constant state.

param
layers The list of layers to add to this drawable.
param
state The constant drawable state.

        this(state, null);

        final int length = layers.length;
        final ChildDrawable[] r = new ChildDrawable[length];
        for (int i = 0; i < length; i++) {
            r[i] = new ChildDrawable();
            r[i].mDrawable = layers[i];
            layers[i].setCallback(this);
            mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations();
        }
        mLayerState.mNum = length;
        mLayerState.mChildren = r;

        ensurePadding();
    
LayerDrawable()

        this((LayerState) null, null);
    
LayerDrawable(LayerState state, android.content.res.Resources res)

        mLayerState = createConstantState(state, res);
        if (mLayerState.mNum > 0) {
            ensurePadding();
        }
    
Methods Summary
voidaddLayer(android.graphics.drawable.LayerDrawable$ChildDrawable layer)

        final LayerState st = mLayerState;
        final int N = st.mChildren != null ? st.mChildren.length : 0;
        final int i = st.mNum;
        if (i >= N) {
            final ChildDrawable[] nu = new ChildDrawable[N + 10];
            if (i > 0) {
                System.arraycopy(st.mChildren, 0, nu, 0, i);
            }

            st.mChildren = nu;
        }

        st.mChildren[i] = layer;
        st.mNum++;
        st.invalidateCache();
    
android.graphics.drawable.LayerDrawable$ChildDrawableaddLayer(Drawable layer, int[] themeAttrs, int id, int left, int top, int right, int bottom)
Add a new layer to this drawable. The new layer is identified by an id.

param
layer The drawable to add as a layer.
param
themeAttrs Theme attributes extracted from the layer.
param
id The id of the new layer.
param
left The left padding of the new layer.
param
top The top padding of the new layer.
param
right The right padding of the new layer.
param
bottom The bottom padding of the new layer.

        final ChildDrawable childDrawable = new ChildDrawable();
        childDrawable.mId = id;
        childDrawable.mThemeAttrs = themeAttrs;
        childDrawable.mDrawable = layer;
        childDrawable.mDrawable.setAutoMirrored(isAutoMirrored());
        childDrawable.mInsetL = left;
        childDrawable.mInsetT = top;
        childDrawable.mInsetR = right;
        childDrawable.mInsetB = bottom;

        addLayer(childDrawable);

        mLayerState.mChildrenChangingConfigurations |= layer.getChangingConfigurations();
        layer.setCallback(this);

        return childDrawable;
    
public voidapplyTheme(android.content.res.Resources.Theme t)

        super.applyTheme(t);

        final LayerState state = mLayerState;
        if (state == null) {
            return;
        }

        if (state.mThemeAttrs != null) {
            final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.LayerDrawable);
            updateStateFromTypedArray(a);
            a.recycle();
        }

        final ChildDrawable[] array = state.mChildren;
        final int N = state.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable layer = array[i];
            if (layer.mThemeAttrs != null) {
                final TypedArray a = t.resolveAttributes(layer.mThemeAttrs,
                        R.styleable.LayerDrawableItem);
                updateLayerFromTypedArray(layer, a);
                a.recycle();
            }

            final Drawable d = layer.mDrawable;
            if (d.canApplyTheme()) {
                d.applyTheme(t);
            }
        }

        ensurePadding();
        onStateChange(getState());
    
public booleancanApplyTheme()

        return (mLayerState != null && mLayerState.canApplyTheme()) || super.canApplyTheme();
    
public voidclearMutated()

hide

        super.clearMutated();
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.clearMutated();
        }
        mMutated = false;
    
private voidcomputeNestedPadding(android.graphics.Rect padding)

        padding.left = 0;
        padding.top = 0;
        padding.right = 0;
        padding.bottom = 0;

        // Add all the padding.
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            refreshChildPadding(i, array[i]);

            padding.left += mPaddingL[i];
            padding.top += mPaddingT[i];
            padding.right += mPaddingR[i];
            padding.bottom += mPaddingB[i];
        }
    
private voidcomputeStackedPadding(android.graphics.Rect padding)

        padding.left = 0;
        padding.top = 0;
        padding.right = 0;
        padding.bottom = 0;

        // Take the max padding.
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            refreshChildPadding(i, array[i]);

            padding.left = Math.max(padding.left, mPaddingL[i]);
            padding.top = Math.max(padding.top, mPaddingT[i]);
            padding.right = Math.max(padding.right, mPaddingR[i]);
            padding.bottom = Math.max(padding.bottom, mPaddingB[i]);
        }
    
android.graphics.drawable.LayerDrawable$LayerStatecreateConstantState(android.graphics.drawable.LayerDrawable$LayerState state, android.content.res.Resources res)

        return new LayerState(state, this, res);
    
public voiddraw(android.graphics.Canvas canvas)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.draw(canvas);
        }
    
voidensurePadding()
Ensures the child padding caches are large enough.

        final int N = mLayerState.mNum;
        if (mPaddingL != null && mPaddingL.length >= N) {
            return;
        }

        mPaddingL = new int[N];
        mPaddingT = new int[N];
        mPaddingR = new int[N];
        mPaddingB = new int[N];
    
public DrawablefindDrawableByLayerId(int id)
Looks for a layer with the given ID and returns its {@link Drawable}.

If multiple layers are found for the given ID, returns the {@link Drawable} for the matching layer at the highest index.

param
id The layer ID to search for.
return
The {@link Drawable} for the highest-indexed layer that has the given ID, or null if not found.

        final ChildDrawable[] layers = mLayerState.mChildren;
        for (int i = mLayerState.mNum - 1; i >= 0; i--) {
            if (layers[i].mId == id) {
                return layers[i].mDrawable;
            }
        }

        return null;
    
public intgetAlpha()

        final ChildDrawable[] array = mLayerState.mChildren;
        if (mLayerState.mNum > 0) {
            // All layers should have the same alpha set on them - just return
            // the first one
            return array[0].mDrawable.getAlpha();
        } else {
            return super.getAlpha();
        }
    
public intgetChangingConfigurations()

        return super.getChangingConfigurations()
                | mLayerState.mChangingConfigurations
                | mLayerState.mChildrenChangingConfigurations;
    
public ConstantStategetConstantState()

        if (mLayerState.canConstantState()) {
            mLayerState.mChangingConfigurations = getChangingConfigurations();
            return mLayerState;
        }
        return null;
    
public DrawablegetDrawable(int index)
Returns the drawable at the specified layer index.

param
index The layer index of the drawable to retrieve.
return
The {@link android.graphics.drawable.Drawable} at the specified layer index.

        return mLayerState.mChildren[index].mDrawable;
    
public voidgetHotspotBounds(android.graphics.Rect outRect)

hide

        if (mHotspotBounds != null) {
            outRect.set(mHotspotBounds);
        } else {
            super.getHotspotBounds(outRect);
        }
    
public intgetId(int index)
Returns the id of the specified layer.

param
index The index of the layer.
return
The id of the layer or {@link android.view.View#NO_ID} if the layer has no id.

        return mLayerState.mChildren[index].mId;
    
public intgetIntrinsicHeight()

        int height = -1;
        int padT = 0;
        int padB = 0;

        final boolean nest = mLayerState.mPaddingMode == PADDING_MODE_NEST;
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable r = array[i];
            int h = r.mDrawable.getIntrinsicHeight() + r.mInsetT + r.mInsetB + padT + padB;
            if (h > height) {
                height = h;
            }

            if (nest) {
                padT += mPaddingT[i];
                padB += mPaddingB[i];
            }
        }

        return height;
    
public intgetIntrinsicWidth()

        int width = -1;
        int padL = 0;
        int padR = 0;

        final boolean nest = mLayerState.mPaddingMode == PADDING_MODE_NEST;
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable r = array[i];
            final int w = r.mDrawable.getIntrinsicWidth() + r.mInsetL + r.mInsetR + padL + padR;
            if (w > width) {
                width = w;
            }

            if (nest) {
                padL += mPaddingL[i];
                padR += mPaddingR[i];
            }
        }

        return width;
    
public intgetNumberOfLayers()
Returns the number of layers contained within this.

return
The number of layers.

        return mLayerState.mNum;
    
public intgetOpacity()

        if (mOpacityOverride != PixelFormat.UNKNOWN) {
            return mOpacityOverride;
        }
        return mLayerState.getOpacity();
    
public voidgetOutline(android.graphics.Outline outline)
Populates outline with the first available (non-empty) layer outline.

param
outline Outline in which to place the first available layer outline

        final LayerState state = mLayerState;
        final ChildDrawable[] children = state.mChildren;
        final int N = state.mNum;
        for (int i = 0; i < N; i++) {
            children[i].mDrawable.getOutline(outline);
            if (!outline.isEmpty()) {
                return;
            }
        }
    
public booleangetPadding(android.graphics.Rect padding)

        if (mLayerState.mPaddingMode == PADDING_MODE_NEST) {
            computeNestedPadding(padding);
        } else {
            computeStackedPadding(padding);
        }

        return padding.left != 0 || padding.top != 0 || padding.right != 0 || padding.bottom != 0;
    
public intgetPaddingMode()

return
the current padding mode
see
#setPaddingMode(int)
attr
ref android.R.styleable#LayerDrawable_paddingMode

      return mLayerState.mPaddingMode;
    
public voidinflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme)

        super.inflate(r, parser, attrs, theme);

        final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.LayerDrawable);
        updateStateFromTypedArray(a);
        a.recycle();

        inflateLayers(r, parser, attrs, theme);

        ensurePadding();
        onStateChange(getState());
    
private voidinflateLayers(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme)
Inflates child layers using the specified parser.

        final LayerState state = mLayerState;

        final int innerDepth = parser.getDepth() + 1;
        int type;
        int depth;
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
                && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
            if (type != XmlPullParser.START_TAG) {
                continue;
            }

            if (depth > innerDepth || !parser.getName().equals("item")) {
                continue;
            }

            final ChildDrawable layer = new ChildDrawable();
            final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.LayerDrawableItem);
            updateLayerFromTypedArray(layer, a);
            a.recycle();

            if (layer.mDrawable == null) {
                while ((type = parser.next()) == XmlPullParser.TEXT) {
                }
                if (type != XmlPullParser.START_TAG) {
                    throw new XmlPullParserException(parser.getPositionDescription()
                            + ": <item> tag requires a 'drawable' attribute or "
                            + "child tag defining a drawable");
                }
                layer.mDrawable = Drawable.createFromXmlInner(r, parser, attrs, theme);
            }

            if (layer.mDrawable != null) {
                state.mChildrenChangingConfigurations |=
                        layer.mDrawable.getChangingConfigurations();
                layer.mDrawable.setCallback(this);
            }

            addLayer(layer);
        }
    
public voidinvalidateDrawable(Drawable who)

        invalidateSelf();
    
public booleanisAutoMirrored()

        return mLayerState.mAutoMirrored;
    
public booleanisProjected()

hide

        if (super.isProjected()) {
            return true;
        }

        final ChildDrawable[] layers = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            if (layers[i].mDrawable.isProjected()) {
                return true;
            }
        }

        return false;
    
public booleanisStateful()

        return mLayerState.isStateful();
    
public Drawablemutate()

        if (!mMutated && super.mutate() == this) {
            mLayerState = createConstantState(mLayerState, null);
            final ChildDrawable[] array = mLayerState.mChildren;
            final int N = mLayerState.mNum;
            for (int i = 0; i < N; i++) {
                array[i].mDrawable.mutate();
            }
            mMutated = true;
        }
        return this;
    
protected voidonBoundsChange(android.graphics.Rect bounds)

        int padL = 0;
        int padT = 0;
        int padR = 0;
        int padB = 0;

        final boolean nest = mLayerState.mPaddingMode == PADDING_MODE_NEST;
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable r = array[i];
            r.mDrawable.setBounds(bounds.left + r.mInsetL + padL, bounds.top + r.mInsetT + padT,
                    bounds.right - r.mInsetR - padR, bounds.bottom - r.mInsetB - padB);

            if (nest) {
                padL += mPaddingL[i];
                padR += mPaddingR[i];
                padT += mPaddingT[i];
                padB += mPaddingB[i];
            }
        }
    
protected booleanonLevelChange(int level)

        boolean paddingChanged = false;
        boolean changed = false;

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable r = array[i];
            if (r.mDrawable.setLevel(level)) {
                changed = true;
            }

            if (refreshChildPadding(i, r)) {
                paddingChanged = true;
            }
        }

        if (paddingChanged) {
            onBoundsChange(getBounds());
        }

        return changed;
    
protected booleanonStateChange(int[] state)

        boolean paddingChanged = false;
        boolean changed = false;

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable r = array[i];
            if (r.mDrawable.isStateful() && r.mDrawable.setState(state)) {
                changed = true;
            }

            if (refreshChildPadding(i, r)) {
                paddingChanged = true;
            }
        }

        if (paddingChanged) {
            onBoundsChange(getBounds());
        }

        return changed;
    
private booleanrefreshChildPadding(int i, android.graphics.drawable.LayerDrawable$ChildDrawable r)
Refreshes the cached padding values for the specified child.

return
true if the child's padding has changed

        final Rect rect = mTmpRect;
        r.mDrawable.getPadding(rect);
        if (rect.left != mPaddingL[i] || rect.top != mPaddingT[i] ||
                rect.right != mPaddingR[i] || rect.bottom != mPaddingB[i]) {
            mPaddingL[i] = rect.left;
            mPaddingT[i] = rect.top;
            mPaddingR[i] = rect.right;
            mPaddingB[i] = rect.bottom;
            return true;
        }
        return false;
    
public voidscheduleDrawable(Drawable who, java.lang.Runnable what, long when)

        scheduleSelf(what, when);
    
public voidsetAlpha(int alpha)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setAlpha(alpha);
        }
    
public voidsetAutoMirrored(boolean mirrored)

        mLayerState.mAutoMirrored = mirrored;

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setAutoMirrored(mirrored);
        }
    
public voidsetColorFilter(android.graphics.ColorFilter cf)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setColorFilter(cf);
        }
    
public voidsetDither(boolean dither)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setDither(dither);
        }
    
public booleansetDrawableByLayerId(int id, Drawable drawable)
Sets (or replaces) the {@link Drawable} for the layer with the given id.

param
id The layer ID to search for.
param
drawable The replacement {@link Drawable}.
return
Whether the {@link Drawable} was replaced (could return false if the id was not found).

        final ChildDrawable[] layers = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            final ChildDrawable childDrawable = layers[i];
            if (childDrawable.mId == id) {
                if (childDrawable.mDrawable != null) {
                    if (drawable != null) {
                        final Rect bounds = childDrawable.mDrawable.getBounds();
                        drawable.setBounds(bounds);
                    }

                    childDrawable.mDrawable.setCallback(null);
                }

                if (drawable != null) {
                    drawable.setCallback(this);
                }

                childDrawable.mDrawable = drawable;
                mLayerState.invalidateCache();
                return true;
            }
        }

        return false;
    
public voidsetHotspot(float x, float y)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setHotspot(x, y);
        }
    
public voidsetHotspotBounds(int left, int top, int right, int bottom)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setHotspotBounds(left, top, right, bottom);
        }

        if (mHotspotBounds == null) {
            mHotspotBounds = new Rect(left, top, right, bottom);
        } else {
            mHotspotBounds.set(left, top, right, bottom);
        }
    
public voidsetId(int index, int id)
Sets the ID of a layer.

param
index The index of the layer which will received the ID.
param
id The ID to assign to the layer.

        mLayerState.mChildren[index].mId = id;
    
public voidsetLayerInset(int index, int l, int t, int r, int b)
Specifies the insets in pixels for the drawable at the specified index.

param
index the index of the drawable to adjust
param
l number of pixels to add to the left bound
param
t number of pixels to add to the top bound
param
r number of pixels to subtract from the right bound
param
b number of pixels to subtract from the bottom bound

        final ChildDrawable childDrawable = mLayerState.mChildren[index];
        childDrawable.mInsetL = l;
        childDrawable.mInsetT = t;
        childDrawable.mInsetR = r;
        childDrawable.mInsetB = b;
    
public voidsetLayoutDirection(int layoutDirection)

hide

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setLayoutDirection(layoutDirection);
        }
        super.setLayoutDirection(layoutDirection);
    
public voidsetOpacity(int opacity)
Sets the opacity of this drawable directly, instead of collecting the states from the layers

param
opacity The opacity to use, or {@link PixelFormat#UNKNOWN PixelFormat.UNKNOWN} for the default behavior
see
PixelFormat#UNKNOWN
see
PixelFormat#TRANSLUCENT
see
PixelFormat#TRANSPARENT
see
PixelFormat#OPAQUE

        mOpacityOverride = opacity;
    
public voidsetPaddingMode(int mode)
Specifies how layer padding should affect the bounds of subsequent layers. The default value is {@link #PADDING_MODE_NEST}.

param
mode padding mode, one of:
  • {@link #PADDING_MODE_NEST} to nest each layer inside the padding of the previous layer
  • {@link #PADDING_MODE_STACK} to stack each layer directly atop the previous layer
see
#getPaddingMode()
attr
ref android.R.styleable#LayerDrawable_paddingMode

        if (mLayerState.mPaddingMode != mode) {
            mLayerState.mPaddingMode = mode;
        }
    
public voidsetTintList(android.content.res.ColorStateList tint)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setTintList(tint);
        }
    
public voidsetTintMode(android.graphics.PorterDuff.Mode tintMode)

        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setTintMode(tintMode);
        }
    
public booleansetVisible(boolean visible, boolean restart)

        final boolean changed = super.setVisible(visible, restart);
        final ChildDrawable[] array = mLayerState.mChildren;
        final int N = mLayerState.mNum;
        for (int i = 0; i < N; i++) {
            array[i].mDrawable.setVisible(visible, restart);
        }

        return changed;
    
public voidunscheduleDrawable(Drawable who, java.lang.Runnable what)

        unscheduleSelf(what);
    
private voidupdateLayerFromTypedArray(android.graphics.drawable.LayerDrawable$ChildDrawable layer, android.content.res.TypedArray a)

        final LayerState state = mLayerState;

        // Account for any configuration changes.
        state.mChildrenChangingConfigurations |= a.getChangingConfigurations();

        // Extract the theme attributes, if any.
        layer.mThemeAttrs = a.extractThemeAttrs();

        layer.mInsetL = a.getDimensionPixelOffset(
                R.styleable.LayerDrawableItem_left, layer.mInsetL);
        layer.mInsetT = a.getDimensionPixelOffset(
                R.styleable.LayerDrawableItem_top, layer.mInsetT);
        layer.mInsetR = a.getDimensionPixelOffset(
                R.styleable.LayerDrawableItem_right, layer.mInsetR);
        layer.mInsetB = a.getDimensionPixelOffset(
                R.styleable.LayerDrawableItem_bottom, layer.mInsetB);
        layer.mId = a.getResourceId(R.styleable.LayerDrawableItem_id, layer.mId);

        final Drawable dr = a.getDrawable(R.styleable.LayerDrawableItem_drawable);
        if (dr != null) {
            layer.mDrawable = dr;
        }
    
private voidupdateStateFromTypedArray(android.content.res.TypedArray a)
Initializes the constant state from the values in the typed array.

        final LayerState state = mLayerState;

        // Account for any configuration changes.
        state.mChangingConfigurations |= a.getChangingConfigurations();

        // Extract the theme attributes, if any.
        state.mThemeAttrs = a.extractThemeAttrs();

        mOpacityOverride = a.getInt(R.styleable.LayerDrawable_opacity, mOpacityOverride);

        state.mAutoMirrored = a.getBoolean(R.styleable.LayerDrawable_autoMirrored,
                state.mAutoMirrored);
        state.mPaddingMode = a.getInteger(R.styleable.LayerDrawable_paddingMode,
                state.mPaddingMode);