当前位置: 首页>>代码示例>>C#>>正文


C# android.clipRect方法代码示例

本文整理汇总了C#中android.clipRect方法的典型用法代码示例。如果您正苦于以下问题:C# android.clipRect方法的具体用法?C# android.clipRect怎么用?C# android.clipRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android的用法示例。


在下文中一共展示了android.clipRect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: draw

		public override void draw(android.graphics.Canvas canvas)
		{
			if (mPicture != null)
			{
				android.graphics.Rect bounds = getBounds();
				canvas.save();
				canvas.clipRect(bounds);
				canvas.translate(bounds.left, bounds.top);
				canvas.drawPicture(mPicture);
				canvas.restore();
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:12,代码来源:PictureDrawable.cs

示例2: drawChild


//.........这里部分代码省略.........
							int layerFlags = android.graphics.Canvas.HAS_ALPHA_LAYER_SAVE_FLAG;
							if ((flags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN || layerType != LAYER_TYPE_NONE)
							{
								layerFlags |= android.graphics.Canvas.CLIP_TO_LAYER_SAVE_FLAG;
							}
							if (layerType == LAYER_TYPE_NONE)
							{
								int scrollX = hasDisplayList ? 0 : sx;
								int scrollY = hasDisplayList ? 0 : sy;
								canvas.saveLayerAlpha(scrollX, scrollY, scrollX + cr - cl, scrollY + cb - ct, multipliedAlpha
									, layerFlags);
							}
						}
						else
						{
							// Alpha is handled by the child directly, clobber the layer's alpha
							child.mPrivateFlags |= ALPHA_SET;
						}
					}
				}
			}
			else
			{
				if ((child.mPrivateFlags & ALPHA_SET) == ALPHA_SET)
				{
					child.onSetAlpha(255);
					child.mPrivateFlags &= ~ALPHA_SET;
				}
			}
			if ((flags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN)
			{
				if (offsetForScroll)
				{
					canvas.clipRect(sx, sy, sx + (cr - cl), sy + (cb - ct));
				}
				else
				{
					if (!scalingRequired || cache == null)
					{
						canvas.clipRect(0, 0, cr - cl, cb - ct);
					}
					else
					{
						canvas.clipRect(0, 0, cache.getWidth(), cache.getHeight());
					}
				}
			}
			if (hasDisplayList)
			{
				displayList = child.getDisplayList();
				if (!displayList.isValid())
				{
					// Uncommon, but possible. If a view is removed from the hierarchy during the call
					// to getDisplayList(), the display list will be marked invalid and we should not
					// try to use it again.
					displayList = null;
					hasDisplayList = false;
				}
			}
			if (hasNoCache)
			{
				bool layerRendered = false;
				if (layerType == LAYER_TYPE_HARDWARE)
				{
					android.view.HardwareLayer layer = child.getHardwareLayer();
					if (layer != null && layer.isValid())
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:67,代码来源:ViewGroup.cs

示例3: dispatchDraw

		protected internal override void dispatchDraw(android.graphics.Canvas canvas)
		{
			int count = mChildrenCount;
			android.view.View[] children = mChildren;
			int flags = mGroupFlags;
			if ((flags & FLAG_RUN_ANIMATION) != 0 && canAnimate())
			{
				bool cache = (mGroupFlags & FLAG_ANIMATION_CACHE) == FLAG_ANIMATION_CACHE;
				bool buildCache = !isHardwareAccelerated();
				{
					for (int i = 0; i < count; i++)
					{
						android.view.View child = children[i];
						if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE)
						{
							android.view.ViewGroup.LayoutParams @params = child.getLayoutParams();
							attachLayoutAnimationParameters(child, @params, i, count);
							bindLayoutAnimation(child);
							if (cache)
							{
								child.setDrawingCacheEnabled(true);
								if (buildCache)
								{
									child.buildDrawingCache(true);
								}
							}
						}
					}
				}
				android.view.animation.LayoutAnimationController controller = mLayoutAnimationController;
				if (controller.willOverlap())
				{
					mGroupFlags |= FLAG_OPTIMIZE_INVALIDATE;
				}
				controller.start();
				mGroupFlags &= ~FLAG_RUN_ANIMATION;
				mGroupFlags &= ~FLAG_ANIMATION_DONE;
				if (cache)
				{
					mGroupFlags |= FLAG_CHILDREN_DRAWN_WITH_CACHE;
				}
				if (mAnimationListener != null)
				{
					mAnimationListener.onAnimationStart(controller.getAnimation());
				}
			}
			int saveCount = 0;
			bool clipToPadding = (flags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK;
			if (clipToPadding)
			{
				saveCount = canvas.save();
				canvas.clipRect(mScrollX + mPaddingLeft, mScrollY + mPaddingTop, mScrollX + mRight
					 - mLeft - mPaddingRight, mScrollY + mBottom - mTop - mPaddingBottom);
			}
			mPrivateFlags &= ~DRAW_ANIMATION;
			mGroupFlags &= ~FLAG_INVALIDATE_REQUIRED;
			bool more = false;
			long drawingTime = getDrawingTime();
			if ((flags & FLAG_USE_CHILD_DRAWING_ORDER) == 0)
			{
				{
					for (int i = 0; i < count; i++)
					{
						android.view.View child = children[i];
						if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null)
						{
							more |= drawChild(canvas, child, drawingTime);
						}
					}
				}
			}
			else
			{
				{
					for (int i = 0; i < count; i++)
					{
						android.view.View child = children[getChildDrawingOrder(count, i)];
						if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null)
						{
							more |= drawChild(canvas, child, drawingTime);
						}
					}
				}
			}
			if (mDisappearingChildren != null)
			{
				java.util.ArrayList<android.view.View> disappearingChildren = mDisappearingChildren;
				int disappearingCount = disappearingChildren.size() - 1;
				{
					for (int i = disappearingCount; i >= 0; i--)
					{
						android.view.View child = disappearingChildren.get(i);
						more |= drawChild(canvas, child, drawingTime);
					}
				}
			}
			if (clipToPadding)
			{
				canvas.restoreToCount(saveCount);
			}
//.........这里部分代码省略.........
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:101,代码来源:ViewGroup.cs

示例4: draw

		public override void draw(android.graphics.Canvas canvas)
		{
			if (mClipState.mDrawable.getLevel() == 0)
			{
				return;
			}
			android.graphics.Rect r = mTmpRect;
			android.graphics.Rect bounds = getBounds();
			int level = getLevel();
			int w = bounds.width();
			int iw = 0;
			//mClipState.mDrawable.getIntrinsicWidth();
			if ((mClipState.mOrientation & HORIZONTAL) != 0)
			{
				w -= (w - iw) * (10000 - level) / 10000;
			}
			int h = bounds.height();
			int ih = 0;
			//mClipState.mDrawable.getIntrinsicHeight();
			if ((mClipState.mOrientation & VERTICAL) != 0)
			{
				h -= (h - ih) * (10000 - level) / 10000;
			}
			int layoutDirection = getResolvedLayoutDirectionSelf();
			android.view.Gravity.apply(mClipState.mGravity, w, h, bounds, r, layoutDirection);
			if (w > 0 && h > 0)
			{
				canvas.save();
				canvas.clipRect(r);
				mClipState.mDrawable.draw(canvas);
				canvas.restore();
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:33,代码来源:ClipDrawable.cs

示例5: onDraw

		protected internal override void onDraw(android.graphics.Canvas canvas)
		{
			if (mSelectorWheelState == SELECTOR_WHEEL_STATE_NONE)
			{
				return;
			}
			float x = (mRight - mLeft) / 2;
			float y = mCurrentScrollOffset;
			int restoreCount = canvas.save();
			if (mSelectorWheelState == SELECTOR_WHEEL_STATE_SMALL)
			{
				android.graphics.Rect clipBounds = canvas.getClipBounds();
				clipBounds.inset(0, mSelectorElementHeight);
				canvas.clipRect(clipBounds);
			}
			// draw the selector wheel
			int[] selectorIndices = mSelectorIndices;
			{
				for (int i = 0; i < selectorIndices.Length; i++)
				{
					int selectorIndex = selectorIndices[i];
					string scrollSelectorValue = mSelectorIndexToStringCache.get(selectorIndex);
					// Do not draw the middle item if input is visible since the input is shown only
					// if the wheel is static and it covers the middle item. Otherwise, if the user
					// starts editing the text via the IME he may see a dimmed version of the old
					// value intermixed with the new one.
					if (i != SELECTOR_MIDDLE_ITEM_INDEX || mInputText.getVisibility() != VISIBLE)
					{
						canvas.drawText(scrollSelectorValue, x, y, mSelectorWheelPaint);
					}
					y += mSelectorElementHeight;
				}
			}
			// draw the selection dividers (only if scrolling and drawable specified)
			if (mSelectionDivider != null)
			{
				// draw the top divider
				int topOfTopDivider = (getHeight() - mSelectorElementHeight - mSelectionDividerHeight
					) / 2;
				int bottomOfTopDivider = topOfTopDivider + mSelectionDividerHeight;
				mSelectionDivider.setBounds(0, topOfTopDivider, mRight, bottomOfTopDivider);
				mSelectionDivider.draw(canvas);
				// draw the bottom divider
				int topOfBottomDivider = topOfTopDivider + mSelectorElementHeight;
				int bottomOfBottomDivider = bottomOfTopDivider + mSelectorElementHeight;
				mSelectionDivider.setBounds(0, topOfBottomDivider, mRight, bottomOfBottomDivider);
				mSelectionDivider.draw(canvas);
			}
			canvas.restoreToCount(restoreCount);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:50,代码来源:NumberPicker.cs

示例6: dispatchDraw

		protected internal override void dispatchDraw(android.graphics.Canvas canvas)
		{
			bool expandClipRegion = false;
			canvas.getClipBounds(stackInvalidateRect);
			int childCount = getChildCount();
			{
				for (int i = 0; i < childCount; i++)
				{
					android.view.View child = getChildAt(i);
					android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
						)child.getLayoutParams();
					if ((lp.horizontalOffset == 0 && lp.verticalOffset == 0) || child.getAlpha() == 0f
						 || child.getVisibility() != VISIBLE)
					{
						lp.resetInvalidateRect();
					}
					android.graphics.Rect childInvalidateRect = lp.getInvalidateRect();
					if (!childInvalidateRect.isEmpty())
					{
						expandClipRegion = true;
						stackInvalidateRect.union(childInvalidateRect);
					}
				}
			}
			// We only expand the clip bounds if necessary.
			if (expandClipRegion)
			{
				canvas.save(android.graphics.Canvas.CLIP_SAVE_FLAG);
				canvas.clipRect(stackInvalidateRect, android.graphics.Region.Op.UNION);
				base.dispatchDraw(canvas);
				canvas.restore();
			}
			else
			{
				base.dispatchDraw(canvas);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:37,代码来源:StackView.cs

示例7: onDraw

		protected internal override void onDraw(android.graphics.Canvas canvas)
		{
			base.onDraw(canvas);
			if (mDrawable == null)
			{
				return;
			}
			// couldn't resolve the URI
			if (mDrawableWidth == 0 || mDrawableHeight == 0)
			{
				return;
			}
			// nothing to draw (empty bounds)
			if (mDrawMatrix == null && mPaddingTop == 0 && mPaddingLeft == 0)
			{
				mDrawable.draw(canvas);
			}
			else
			{
				int saveCount = canvas.getSaveCount();
				canvas.save();
				if (mCropToPadding)
				{
					int scrollX = mScrollX;
					int scrollY = mScrollY;
					canvas.clipRect(scrollX + mPaddingLeft, scrollY + mPaddingTop, scrollX + mRight -
						 mLeft - mPaddingRight, scrollY + mBottom - mTop - mPaddingBottom);
				}
				canvas.translate(mPaddingLeft, mPaddingTop);
				if (mDrawMatrix != null)
				{
					canvas.concat(mDrawMatrix);
				}
				mDrawable.draw(canvas);
				canvas.restoreToCount(saveCount);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:37,代码来源:ImageView.cs


注:本文中的android.clipRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。