コード例 #1
0
ファイル: Gallery.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>Figure out vertical placement based on mGravity</summary>
		/// <param name="child">Child to place</param>
		/// <returns>Where the top of the child should be</returns>
		private int calculateTop(android.view.View child, bool duringLayout)
		{
			int myHeight = duringLayout ? getMeasuredHeight() : getHeight();
			int childHeight = duringLayout ? child.getMeasuredHeight() : child.getHeight();
			int childTop = 0;
			switch (mGravity)
			{
				case android.view.Gravity.TOP:
				{
					childTop = mSpinnerPadding.top;
					break;
				}

				case android.view.Gravity.CENTER_VERTICAL:
				{
					int availableSpace = myHeight - mSpinnerPadding.bottom - mSpinnerPadding.top - childHeight;
					childTop = mSpinnerPadding.top + (availableSpace / 2);
					break;
				}

				case android.view.Gravity.BOTTOM:
				{
					childTop = myHeight - mSpinnerPadding.bottom - childHeight;
					break;
				}
			}
			return childTop;
		}
コード例 #2
0
ファイル: Spinner.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>
		/// Helper for makeAndAddView to set the position of a view
		/// and fill out its layout paramters.
		/// </summary>
		/// <remarks>
		/// Helper for makeAndAddView to set the position of a view
		/// and fill out its layout paramters.
		/// </remarks>
		/// <param name="child">The view to position</param>
		private void setUpChild(android.view.View child)
		{
			// Respect layout params that are already in the view. Otherwise
			// make some up...
			android.view.ViewGroup.LayoutParams lp = child.getLayoutParams();
			if (lp == null)
			{
				lp = generateDefaultLayoutParams();
			}
			addViewInLayout(child, 0, lp);
			child.setSelected(hasFocus());
			// Get measure specs
			int childHeightSpec = android.view.ViewGroup.getChildMeasureSpec(mHeightMeasureSpec
				, mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height);
			int childWidthSpec = android.view.ViewGroup.getChildMeasureSpec(mWidthMeasureSpec
				, mSpinnerPadding.left + mSpinnerPadding.right, lp.width);
			// Measure child
			child.measure(childWidthSpec, childHeightSpec);
			int childLeft;
			int childRight;
			// Position vertically based on gravity setting
			int childTop = mSpinnerPadding.top + ((getMeasuredHeight() - mSpinnerPadding.bottom
				 - mSpinnerPadding.top - child.getMeasuredHeight()) / 2);
			int childBottom = childTop + child.getMeasuredHeight();
			int width = child.getMeasuredWidth();
			childLeft = 0;
			childRight = childLeft + width;
			child.layout(childLeft, childTop, childRight, childBottom);
		}
コード例 #3
0
ファイル: Gallery.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>
		/// Helper for makeAndAddView to set the position of a view and fill out its
		/// layout parameters.
		/// </summary>
		/// <remarks>
		/// Helper for makeAndAddView to set the position of a view and fill out its
		/// layout parameters.
		/// </remarks>
		/// <param name="child">The view to position</param>
		/// <param name="offset">Offset from the selected position</param>
		/// <param name="x">
		/// X-coordinate indicating where this view should be placed. This
		/// will either be the left or right edge of the view, depending on
		/// the fromLeft parameter
		/// </param>
		/// <param name="fromLeft">
		/// Are we positioning views based on the left edge? (i.e.,
		/// building from left to right)?
		/// </param>
		private void setUpChild(android.view.View child, int offset, int x, bool fromLeft
			)
		{
			// Respect layout params that are already in the view. Otherwise
			// make some up...
			android.widget.Gallery.LayoutParams lp = (android.widget.Gallery.LayoutParams)child
				.getLayoutParams();
			if (lp == null)
			{
				lp = (android.widget.Gallery.LayoutParams)generateDefaultLayoutParams();
			}
			addViewInLayout(child, fromLeft != mIsRtl ? -1 : 0, lp);
			child.setSelected(offset == 0);
			// Get measure specs
			int childHeightSpec = android.view.ViewGroup.getChildMeasureSpec(mHeightMeasureSpec
				, mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height);
			int childWidthSpec = android.view.ViewGroup.getChildMeasureSpec(mWidthMeasureSpec
				, mSpinnerPadding.left + mSpinnerPadding.right, lp.width);
			// Measure child
			child.measure(childWidthSpec, childHeightSpec);
			int childLeft;
			int childRight;
			// Position vertically based on gravity setting
			int childTop = calculateTop(child, true);
			int childBottom = childTop + child.getMeasuredHeight();
			int width = child.getMeasuredWidth();
			if (fromLeft)
			{
				childLeft = x;
				childRight = childLeft + width;
			}
			else
			{
				childLeft = x - width;
				childRight = x;
			}
			child.layout(childLeft, childTop, childRight, childBottom);
		}
コード例 #4
0
ファイル: Gallery.cs プロジェクト: hakeemsm/XobotOS
		internal override int getChildHeight(android.view.View child)
		{
			return child.getMeasuredHeight();
		}
コード例 #5
0
ファイル: StackView.cs プロジェクト: hakeemsm/XobotOS
			internal virtual android.graphics.Bitmap createOutline(android.view.View v, int type
				, int color)
			{
				mHolographicPaint.setColor(color);
				if (type == RES_OUT)
				{
					mBlurPaint.setMaskFilter(mSmallBlurMaskFilter);
				}
				else
				{
					if (type == CLICK_FEEDBACK)
					{
						mBlurPaint.setMaskFilter(mLargeBlurMaskFilter);
					}
				}
				if (v.getMeasuredWidth() == 0 || v.getMeasuredHeight() == 0)
				{
					return null;
				}
				android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(v.getMeasuredWidth
					(), v.getMeasuredHeight(), android.graphics.Bitmap.Config.ARGB_8888);
				mCanvas.setBitmap(bitmap);
				float rotationX = v.getRotationX();
				float rotation = v.getRotation();
				float translationY = v.getTranslationY();
				float translationX = v.getTranslationX();
				v.setRotationX(0);
				v.setRotation(0);
				v.setTranslationY(0);
				v.setTranslationX(0);
				v.draw(mCanvas);
				v.setRotationX(rotationX);
				v.setRotation(rotation);
				v.setTranslationY(translationY);
				v.setTranslationX(translationX);
				drawOutline(mCanvas, bitmap);
				mCanvas.setBitmap(null);
				return bitmap;
			}
コード例 #6
0
ファイル: GridView.cs プロジェクト: hakeemsm/XobotOS
		/// <summary>
		/// Add a view as a child and make sure it is measured (if necessary) and
		/// positioned properly.
		/// </summary>
		/// <remarks>
		/// Add a view as a child and make sure it is measured (if necessary) and
		/// positioned properly.
		/// </remarks>
		/// <param name="child">The view to add</param>
		/// <param name="position">The position of the view</param>
		/// <param name="y">The y position relative to which this view will be positioned</param>
		/// <param name="flow">
		/// if true, align top edge to y. If false, align bottom edge
		/// to y.
		/// </param>
		/// <param name="childrenLeft">Left edge where children should be positioned</param>
		/// <param name="selected">Is this position selected?</param>
		/// <param name="recycled">
		/// Has this view been pulled from the recycle bin? If so it
		/// does not need to be remeasured.
		/// </param>
		/// <param name="where">Where to add the item in the list</param>
		private void setupChild(android.view.View child, int position, int y, bool flow, 
			int childrenLeft, bool selected, bool recycled, int where)
		{
			bool isSelected_1 = selected && shouldShowSelector();
			bool updateChildSelected = isSelected_1 != child.isSelected();
			int mode = mTouchMode;
			bool isPressed_1 = mode > TOUCH_MODE_DOWN && mode < TOUCH_MODE_SCROLL && mMotionPosition
				 == position;
			bool updateChildPressed = isPressed_1 != child.isPressed();
			bool needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested(
				);
			// Respect layout params that are already in the view. Otherwise make
			// some up...
			android.widget.AbsListView.LayoutParams p = (android.widget.AbsListView.LayoutParams
				)child.getLayoutParams();
			if (p == null)
			{
				p = new android.widget.AbsListView.LayoutParams(android.view.ViewGroup.LayoutParams
					.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0);
			}
			p.viewType = mAdapter.getItemViewType(position);
			if (recycled && !p.forceAdd)
			{
				attachViewToParent(child, where, p);
			}
			else
			{
				p.forceAdd = false;
				addViewInLayout(child, where, p, true);
			}
			if (updateChildSelected)
			{
				child.setSelected(isSelected_1);
				if (isSelected_1)
				{
					requestFocus();
				}
			}
			if (updateChildPressed)
			{
				child.setPressed(isPressed_1);
			}
			if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null)
			{
				if (child is android.widget.Checkable)
				{
					((android.widget.Checkable)child).setChecked(mCheckStates.get(position));
				}
				else
				{
					if (getContext().getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES
						.HONEYCOMB)
					{
						child.setActivated(mCheckStates.get(position));
					}
				}
			}
			if (needToMeasure)
			{
				int childHeightSpec = android.view.ViewGroup.getChildMeasureSpec(android.view.View
					.MeasureSpec.makeMeasureSpec(0, android.view.View.MeasureSpec.UNSPECIFIED), 0, p
					.height);
				int childWidthSpec = android.view.ViewGroup.getChildMeasureSpec(android.view.View
					.MeasureSpec.makeMeasureSpec(mColumnWidth, android.view.View.MeasureSpec.EXACTLY
					), 0, p.width);
				child.measure(childWidthSpec, childHeightSpec);
			}
			else
			{
				cleanupLayoutState(child);
			}
			int w = child.getMeasuredWidth();
			int h = child.getMeasuredHeight();
			int childLeft;
			int childTop = flow ? y : y - h;
			int layoutDirection = getResolvedLayoutDirection();
			int absoluteGravity = android.view.Gravity.getAbsoluteGravity(mGravity, layoutDirection
				);
			switch (absoluteGravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK)
			{
				case android.view.Gravity.LEFT:
				{
					childLeft = childrenLeft;
					break;
				}

				case android.view.Gravity.CENTER_HORIZONTAL:
				{
					childLeft = childrenLeft + ((mColumnWidth - w) / 2);
					break;
				}

				case android.view.Gravity.RIGHT:
				{
					childLeft = childrenLeft + mColumnWidth - w;
					break;
				}

				default:
				{
					childLeft = childrenLeft;
					break;
				}
			}
			if (needToMeasure)
			{
				int childRight = childLeft + w;
				int childBottom = childTop + h;
				child.layout(childLeft, childTop, childRight, childBottom);
			}
			else
			{
				child.offsetLeftAndRight(childLeft - child.getLeft());
				child.offsetTopAndBottom(childTop - child.getTop());
			}
			if (mCachingStarted)
			{
				child.setDrawingCacheEnabled(true);
			}
			if (recycled && (((android.widget.AbsListView.LayoutParams)child.getLayoutParams(
				)).scrappedFromPosition) != position)
			{
				child.jumpDrawablesToCurrentState();
			}
		}
コード例 #7
0
ファイル: AbsActionBarView.cs プロジェクト: hakeemsm/XobotOS
		protected internal virtual int positionChildInverse(android.view.View child, int 
			x, int y, int contentHeight)
		{
			int childWidth = child.getMeasuredWidth();
			int childHeight = child.getMeasuredHeight();
			int childTop = y + (contentHeight - childHeight) / 2;
			child.layout(x - childWidth, childTop, x, childTop + childHeight);
			return childWidth;
		}