Example #1
0
		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);
		}
Example #2
0
		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);
			}
		}