Esempio n. 1
0
		/// <param name="orientation">
		/// Bitwise-or of
		/// <see cref="HORIZONTAL">HORIZONTAL</see>
		/// and/or
		/// <see cref="VERTICAL">VERTICAL</see>
		/// </param>
		public ClipDrawable(android.graphics.drawable.Drawable drawable, int gravity, int
			 orientation) : this(null, null)
		{
			mClipState.mDrawable = drawable;
			mClipState.mGravity = gravity;
			mClipState.mOrientation = orientation;
			if (drawable != null)
			{
				drawable.setCallback(this);
			}
		}
Esempio n. 2
0
		public ScaleDrawable(android.graphics.drawable.Drawable drawable, int gravity, float
			 scaleWidth, float scaleHeight) : this(null, null)
		{
			mScaleState.mDrawable = drawable;
			mScaleState.mGravity = gravity;
			mScaleState.mScaleWidth = scaleWidth;
			mScaleState.mScaleHeight = scaleHeight;
			if (drawable != null)
			{
				drawable.setCallback(this);
			}
		}
Esempio n. 3
0
		public InsetDrawable(android.graphics.drawable.Drawable drawable, int insetLeft, 
			int insetTop, int insetRight, int insetBottom) : this(null, null)
		{
			// Most of this is copied from ScaleDrawable.
			mInsetState.mDrawable = drawable;
			mInsetState.mInsetLeft = insetLeft;
			mInsetState.mInsetTop = insetTop;
			mInsetState.mInsetRight = insetRight;
			mInsetState.mInsetBottom = insetBottom;
			if (drawable != null)
			{
				drawable.setCallback(this);
			}
		}
Esempio n. 4
0
		/// <summary>Sets the thumb that will be drawn at the end of the progress meter within the SeekBar.
		/// 	</summary>
		/// <remarks>
		/// Sets the thumb that will be drawn at the end of the progress meter within the SeekBar.
		/// <p>
		/// If the thumb is a valid drawable (i.e. not null), half its width will be
		/// used as the new thumb offset (@see #setThumbOffset(int)).
		/// </remarks>
		/// <param name="thumb">Drawable representing the thumb</param>
		public virtual void setThumb(android.graphics.drawable.Drawable thumb)
		{
			bool needUpdate;
			// This way, calling setThumb again with the same bitmap will result in
			// it recalcuating mThumbOffset (if for example it the bounds of the
			// drawable changed)
			if (mThumb != null && thumb != mThumb)
			{
				mThumb.setCallback(null);
				needUpdate = true;
			}
			else
			{
				needUpdate = false;
			}
			if (thumb != null)
			{
				thumb.setCallback(this);
				// Assuming the thumb drawable is symmetric, set the thumb offset
				// such that the thumb will hang halfway off either edge of the
				// progress bar.
				mThumbOffset = thumb.getIntrinsicWidth() / 2;
				// If we're updating get the new states
				if (needUpdate && (thumb.getIntrinsicWidth() != mThumb.getIntrinsicWidth() || thumb
					.getIntrinsicHeight() != mThumb.getIntrinsicHeight()))
				{
					requestLayout();
				}
			}
			mThumb = thumb;
			invalidate();
			if (needUpdate)
			{
				updateThumbPos(getWidth(), getHeight());
				if (thumb.isStateful())
				{
					// Note that if the states are different this won't work.
					// For now, let's consider that an app bug.
					int[] state = getDrawableState();
					thumb.setState(state);
				}
			}
		}
Esempio n. 5
0
		/// <summary>Set the checkmark to a given Drawable.</summary>
		/// <remarks>
		/// Set the checkmark to a given Drawable. This will be drawn when
		/// <see cref="isChecked()">isChecked()</see>
		/// is true.
		/// </remarks>
		/// <param name="d">The Drawable to use for the checkmark.</param>
		public virtual void setCheckMarkDrawable(android.graphics.drawable.Drawable d)
		{
			if (mCheckMarkDrawable != null)
			{
				mCheckMarkDrawable.setCallback(null);
				unscheduleDrawable(mCheckMarkDrawable);
			}
			mNeedRequestlayout = (d != mCheckMarkDrawable);
			if (d != null)
			{
				d.setCallback(this);
				d.setVisible(getVisibility() == VISIBLE, false);
				d.setState(CHECKED_STATE_SET);
				setMinHeight(d.getIntrinsicHeight());
				mCheckMarkWidth = d.getIntrinsicWidth();
				d.setState(getDrawableState());
			}
			else
			{
				mCheckMarkWidth = 0;
			}
			mCheckMarkDrawable = d;
			// Do padding resolution. This will call setPadding() and do a requestLayout() if needed.
			resolvePadding();
		}
Esempio n. 6
0
		/// <summary>
		/// Sets (or replaces) the
		/// <see cref="Drawable">Drawable</see>
		/// for the layer with the given id.
		/// </summary>
		/// <param name="id">The layer ID to search for.</param>
		/// <param name="drawable">
		/// The replacement
		/// <see cref="Drawable">Drawable</see>
		/// .
		/// </param>
		/// <returns>
		/// Whether the
		/// <see cref="Drawable">Drawable</see>
		/// was replaced (could return false if
		/// the id was not found).
		/// </returns>
		public virtual bool setDrawableByLayerId(int id, android.graphics.drawable.Drawable
			 drawable)
		{
			android.graphics.drawable.LayerDrawable.ChildDrawable[] layers = mLayerState.mChildren;
			{
				for (int i = mLayerState.mNum - 1; i >= 0; i--)
				{
					if (layers[i].mId == id)
					{
						if (layers[i].mDrawable != null)
						{
							if (drawable != null)
							{
								android.graphics.Rect bounds = layers[i].mDrawable.getBounds();
								drawable.setBounds(bounds);
							}
							layers[i].mDrawable.setCallback(null);
						}
						if (drawable != null)
						{
							drawable.setCallback(this);
						}
						layers[i].mDrawable = drawable;
						return true;
					}
				}
			}
			return false;
		}
Esempio n. 7
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);
		}
Esempio n. 8
0
			public int addChild(android.graphics.drawable.Drawable dr)
			{
				int pos = mNumChildren;
				if (pos >= mDrawables.Length)
				{
					growArray(pos, pos + 10);
				}
				dr.setVisible(false, true);
				dr.setCallback(mOwner);
				mDrawables[pos] = dr;
				mNumChildren++;
				mChildrenChangingConfigurations |= dr.getChangingConfigurations();
				mHaveOpacity = false;
				mHaveStateful = false;
				mConstantPadding = null;
				mPaddingChecked = false;
				mComputedConstantSize = false;
				return pos;
			}
Esempio n. 9
0
		/// <summary>
		/// Supply a Drawable that is to be rendered on top of all of the child
		/// views in the frame layout.
		/// </summary>
		/// <remarks>
		/// Supply a Drawable that is to be rendered on top of all of the child
		/// views in the frame layout.  Any padding in the Drawable will be taken
		/// into account by ensuring that the children are inset to be placed
		/// inside of the padding area.
		/// </remarks>
		/// <param name="drawable">The Drawable to be drawn on top of the children.</param>
		/// <attr>ref android.R.styleable#FrameLayout_foreground</attr>
		public virtual void setForeground(android.graphics.drawable.Drawable drawable)
		{
			if (mForeground != drawable)
			{
				if (mForeground != null)
				{
					mForeground.setCallback(null);
					unscheduleDrawable(mForeground);
				}
				mForeground = drawable;
				mForegroundPaddingLeft = 0;
				mForegroundPaddingTop = 0;
				mForegroundPaddingRight = 0;
				mForegroundPaddingBottom = 0;
				if (drawable != null)
				{
					setWillNotDraw(false);
					drawable.setCallback(this);
					if (drawable.isStateful())
					{
						drawable.setState(getDrawableState());
					}
					if (mForegroundGravity == android.view.Gravity.FILL)
					{
						android.graphics.Rect padding = new android.graphics.Rect();
						if (drawable.getPadding(padding))
						{
							mForegroundPaddingLeft = padding.left;
							mForegroundPaddingTop = padding.top;
							mForegroundPaddingRight = padding.right;
							mForegroundPaddingBottom = padding.bottom;
						}
					}
				}
				else
				{
					setWillNotDraw(true);
				}
				requestLayout();
				invalidate();
			}
		}
Esempio n. 10
0
		private void updateDrawable(android.graphics.drawable.Drawable d)
		{
			if (mDrawable != null)
			{
				mDrawable.setCallback(null);
				unscheduleDrawable(mDrawable);
			}
			mDrawable = d;
			if (d != null)
			{
				d.setCallback(this);
				if (d.isStateful())
				{
					d.setState(getDrawableState());
				}
				d.setLevel(mLevel);
				mDrawableWidth = d.getIntrinsicWidth();
				mDrawableHeight = d.getIntrinsicHeight();
				applyColorMod();
				configureBounds();
			}
			else
			{
				mDrawableWidth = mDrawableHeight = -1;
			}
		}