Example #1
0
        /// <summary>Add a new layer to this drawable.</summary>
        /// <remarks>Add a new layer to this drawable. The new layer is identified by an id.</remarks>
        /// <param name="layer">The drawable to add as a layer.</param>
        /// <param name="id">The id of the new layer.</param>
        /// <param name="left">The left padding of the new layer.</param>
        /// <param name="top">The top padding of the new layer.</param>
        /// <param name="right">The right padding of the new layer.</param>
        /// <param name="bottom">The bottom padding of the new layer.</param>
        private void addLayer(android.graphics.drawable.Drawable layer, int id, int left,
                              int top, int right, int bottom)
        {
            android.graphics.drawable.LayerDrawable.LayerState st = mLayerState;
            int N = st.mChildren != null ? st.mChildren.Length : 0;
            int i = st.mNum;

            if (i >= N)
            {
                android.graphics.drawable.LayerDrawable.ChildDrawable[] nu = new android.graphics.drawable.LayerDrawable
                                                                             .ChildDrawable[N + 10];
                if (i > 0)
                {
                    System.Array.Copy(st.mChildren, 0, nu, 0, i);
                }
                st.mChildren = nu;
            }
            mLayerState.mChildrenChangingConfigurations |= layer.getChangingConfigurations();
            android.graphics.drawable.LayerDrawable.ChildDrawable childDrawable = new android.graphics.drawable.LayerDrawable
                                                                                  .ChildDrawable();
            st.mChildren[i]         = childDrawable;
            childDrawable.mId       = id;
            childDrawable.mDrawable = layer;
            childDrawable.mInsetL   = left;
            childDrawable.mInsetT   = top;
            childDrawable.mInsetR   = right;
            childDrawable.mInsetB   = bottom;
            st.mNum++;
            layer.setCallback(this);
        }
Example #2
0
 internal override android.graphics.drawable.LayerDrawable.LayerState createConstantState
     (android.graphics.drawable.LayerDrawable.LayerState state, android.content.res.Resources
     res)
 {
     return(new android.graphics.drawable.TransitionDrawable.TransitionState((android.graphics.drawable.TransitionDrawable
                                                                              .TransitionState)state, this, res));
 }
Example #3
0
 internal LayerDrawable(android.graphics.drawable.LayerDrawable.LayerState state,
                        android.content.res.Resources res)
 {
     android.graphics.drawable.LayerDrawable.LayerState @as = createConstantState(state
                                                                                  , res);
     mLayerState = @as;
     if (@as.mNum > 0)
     {
         ensurePadding();
     }
 }
Example #4
0
 internal LayerState(android.graphics.drawable.LayerDrawable.LayerState orig, android.graphics.drawable.LayerDrawable
                     owner, android.content.res.Resources res)
 {
     if (orig != null)
     {
         android.graphics.drawable.LayerDrawable.ChildDrawable[] origChildDrawable = orig.
                                                                                     mChildren;
         int N = orig.mNum;
         mNum      = N;
         mChildren = new android.graphics.drawable.LayerDrawable.ChildDrawable[N];
         mChangingConfigurations         = orig.mChangingConfigurations;
         mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations;
         {
             for (int i = 0; i < N; i++)
             {
                 android.graphics.drawable.LayerDrawable.ChildDrawable r = mChildren[i] = new android.graphics.drawable.LayerDrawable
                                                                                          .ChildDrawable();
                 android.graphics.drawable.LayerDrawable.ChildDrawable or = origChildDrawable[i];
                 if (res != null)
                 {
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable(res);
                 }
                 else
                 {
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable();
                 }
                 r.mDrawable.setCallback(owner);
                 r.mInsetL = or.mInsetL;
                 r.mInsetT = or.mInsetT;
                 r.mInsetR = or.mInsetR;
                 r.mInsetB = or.mInsetB;
                 r.mId     = or.mId;
             }
         }
         mHaveOpacity          = orig.mHaveOpacity;
         mOpacity              = orig.mOpacity;
         mHaveStateful         = orig.mHaveStateful;
         mStateful             = orig.mStateful;
         mCheckedConstantState = mCanConstantState = true;
     }
     else
     {
         mNum      = 0;
         mChildren = null;
     }
 }
Example #5
0
        /// <summary>
        /// Create a new layer drawable with the specified list of layers and the specified
        /// constant state.
        /// </summary>
        /// <remarks>
        /// Create a new layer drawable with the specified list of layers and the specified
        /// constant state.
        /// </remarks>
        /// <param name="layers">The list of layers to add to this drawable.</param>
        /// <param name="state">The constant drawable state.</param>
        internal LayerDrawable(android.graphics.drawable.Drawable[] layers, android.graphics.drawable.LayerDrawable
                               .LayerState state) : this(state, null)
        {
            int length = layers.Length;

            android.graphics.drawable.LayerDrawable.ChildDrawable[] r = new android.graphics.drawable.LayerDrawable
                                                                        .ChildDrawable[length];
            {
                for (int i = 0; i < length; i++)
                {
                    r[i]           = new android.graphics.drawable.LayerDrawable.ChildDrawable();
                    r[i].mDrawable = layers[i];
                    layers[i].setCallback(this);
                    mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations
                                                                       ();
                }
            }
            mLayerState.mNum      = length;
            mLayerState.mChildren = r;
            ensurePadding();
        }
Example #6
0
 internal virtual android.graphics.drawable.LayerDrawable.LayerState createConstantState
     (android.graphics.drawable.LayerDrawable.LayerState state, android.content.res.Resources
     res)
 {
     return(new android.graphics.drawable.LayerDrawable.LayerState(state, this, res));
 }
Example #7
0
		internal LayerDrawable(android.graphics.drawable.LayerDrawable.LayerState state, 
			android.content.res.Resources res)
		{
			android.graphics.drawable.LayerDrawable.LayerState @as = createConstantState(state
				, res);
			mLayerState = @as;
			if (@as.mNum > 0)
			{
				ensurePadding();
			}
		}