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


C# android.measure方法代码示例

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


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

示例1: measureChildWithMargins

		/// <summary>
		/// Ask one of the children of this view to measure itself, taking into
		/// account both the MeasureSpec requirements for this view and its padding
		/// and margins.
		/// </summary>
		/// <remarks>
		/// Ask one of the children of this view to measure itself, taking into
		/// account both the MeasureSpec requirements for this view and its padding
		/// and margins. The child must have MarginLayoutParams The heavy lifting is
		/// done in getChildMeasureSpec.
		/// </remarks>
		/// <param name="child">The child to measure</param>
		/// <param name="parentWidthMeasureSpec">The width requirements for this view</param>
		/// <param name="widthUsed">
		/// Extra space that has been used up by the parent
		/// horizontally (possibly by other children of the parent)
		/// </param>
		/// <param name="parentHeightMeasureSpec">The height requirements for this view</param>
		/// <param name="heightUsed">
		/// Extra space that has been used up by the parent
		/// vertically (possibly by other children of the parent)
		/// </param>
		protected internal virtual void measureChildWithMargins(android.view.View child, 
			int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed
			)
		{
			android.view.ViewGroup.MarginLayoutParams lp = (android.view.ViewGroup.MarginLayoutParams
				)child.getLayoutParams();
			int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft
				 + mPaddingRight + lp.leftMargin + lp.rightMargin + widthUsed, lp.width);
			int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop
				 + mPaddingBottom + lp.topMargin + lp.bottomMargin + heightUsed, lp.height);
			child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:34,代码来源:ViewGroup.cs

示例2: setUpChild

		/// <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);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:38,代码来源:Spinner.cs

示例3: measureChild

		/// <summary>
		/// Ask one of the children of this view to measure itself, taking into
		/// account both the MeasureSpec requirements for this view and its padding.
		/// </summary>
		/// <remarks>
		/// Ask one of the children of this view to measure itself, taking into
		/// account both the MeasureSpec requirements for this view and its padding.
		/// The heavy lifting is done in getChildMeasureSpec.
		/// </remarks>
		/// <param name="child">The child to measure</param>
		/// <param name="parentWidthMeasureSpec">The width requirements for this view</param>
		/// <param name="parentHeightMeasureSpec">The height requirements for this view</param>
		protected internal virtual void measureChild(android.view.View child, int parentWidthMeasureSpec
			, int parentHeightMeasureSpec)
		{
			android.view.ViewGroup.LayoutParams lp = child.getLayoutParams();
			int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, mPaddingLeft
				 + mPaddingRight, lp.width);
			int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop
				 + mPaddingBottom, lp.height);
			child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:22,代码来源:ViewGroup.cs

示例4: measureChildWithMargins

		protected internal override void measureChildWithMargins(android.view.View child, 
			int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed
			)
		{
			android.view.ViewGroup.MarginLayoutParams lp = (android.view.ViewGroup.MarginLayoutParams
				)child.getLayoutParams();
			int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop
				 + mPaddingBottom + lp.topMargin + lp.bottomMargin + heightUsed, lp.height);
			int childWidthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(lp.leftMargin
				 + lp.rightMargin, android.view.View.MeasureSpec.UNSPECIFIED);
			child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:12,代码来源:HorizontalScrollView.cs

示例5: setUpChild

		/// <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);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:57,代码来源:Gallery.cs

示例6: measureChild

		protected internal override void measureChild(android.view.View child, int parentWidthMeasureSpec
			, int parentHeightMeasureSpec)
		{
			android.view.ViewGroup.LayoutParams lp = child.getLayoutParams();
			int childWidthMeasureSpec;
			int childHeightMeasureSpec;
			childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop
				 + mPaddingBottom, lp.height);
			childWidthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View
				.MeasureSpec.UNSPECIFIED);
			child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:12,代码来源:HorizontalScrollView.cs

示例7: measureChildBeforeLayout

		internal override void measureChildBeforeLayout(android.view.View child, int childIndex
			, int widthMeasureSpec, int totalWidth, int heightMeasureSpec, int totalHeight)
		{
			if (mConstrainedColumnWidths != null)
			{
				android.widget.TableRow.LayoutParams lp = (android.widget.TableRow.LayoutParams)child
					.getLayoutParams();
				int measureMode = android.view.View.MeasureSpec.EXACTLY;
				int columnWidth = 0;
				int span = lp.span;
				int[] constrainedColumnWidths = mConstrainedColumnWidths;
				{
					for (int i = 0; i < span; i++)
					{
						columnWidth += constrainedColumnWidths[childIndex + i];
					}
				}
				int gravity = lp.gravity;
				bool isHorizontalGravity = android.view.Gravity.isHorizontal(gravity);
				if (isHorizontalGravity)
				{
					measureMode = android.view.View.MeasureSpec.AT_MOST;
				}
				// no need to care about padding here,
				// ViewGroup.getChildMeasureSpec() would get rid of it anyway
				// because of the EXACTLY measure spec we use
				int childWidthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(System.Math.Max
					(0, columnWidth - lp.leftMargin - lp.rightMargin), measureMode);
				int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, mPaddingTop +
					 mPaddingBottom + lp.topMargin + lp.bottomMargin + totalHeight, lp.height);
				child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
				if (isHorizontalGravity)
				{
					int childWidth = child.getMeasuredWidth();
					lp.mOffset[android.widget.TableRow.LayoutParams.LOCATION_NEXT] = columnWidth - childWidth;
					int layoutDirection = getResolvedLayoutDirection();
					int absoluteGravity = android.view.Gravity.getAbsoluteGravity(gravity, layoutDirection
						);
					switch (absoluteGravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK)
					{
						case android.view.Gravity.LEFT:
						{
							// don't offset on X axis
							break;
						}

						case android.view.Gravity.RIGHT:
						{
							lp.mOffset[android.widget.TableRow.LayoutParams.LOCATION] = lp.mOffset[android.widget.TableRow
								.LayoutParams.LOCATION_NEXT];
							break;
						}

						case android.view.Gravity.CENTER_HORIZONTAL:
						{
							lp.mOffset[android.widget.TableRow.LayoutParams.LOCATION] = lp.mOffset[android.widget.TableRow
								.LayoutParams.LOCATION_NEXT] / 2;
							break;
						}
					}
				}
				else
				{
					lp.mOffset[android.widget.TableRow.LayoutParams.LOCATION] = lp.mOffset[android.widget.TableRow
						.LayoutParams.LOCATION_NEXT] = 0;
				}
			}
			else
			{
				// fail silently when column widths are not available
				base.measureChildBeforeLayout(child, childIndex, widthMeasureSpec, totalWidth, heightMeasureSpec
					, totalHeight);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:74,代码来源:TableRow.cs

示例8: measureChildForCells

		/// <summary>Measure a child view to fit within cell-based formatting.</summary>
		/// <remarks>
		/// Measure a child view to fit within cell-based formatting. The child's width
		/// will be measured to a whole multiple of cellSize.
		/// <p>Sets the expandable and cellsUsed fields of LayoutParams.
		/// </remarks>
		/// <param name="child">Child to measure</param>
		/// <param name="cellSize">Size of one cell</param>
		/// <param name="cellsRemaining">Number of cells remaining that this view can expand to fill
		/// 	</param>
		/// <param name="parentHeightMeasureSpec">MeasureSpec used by the parent view</param>
		/// <param name="parentHeightPadding">Padding present in the parent view</param>
		/// <returns>Number of cells this child was measured to occupy</returns>
		internal static int measureChildForCells(android.view.View child, int cellSize, int
			 cellsRemaining, int parentHeightMeasureSpec, int parentHeightPadding)
		{
			[email protected] lp = ([email protected]
				.LayoutParams)child.getLayoutParams();
			int childHeightSize = android.view.View.MeasureSpec.getSize(parentHeightMeasureSpec
				) - parentHeightPadding;
			int childHeightMode = android.view.View.MeasureSpec.getMode(parentHeightMeasureSpec
				);
			int childHeightSpec = android.view.View.MeasureSpec.makeMeasureSpec(childHeightSize
				, childHeightMode);
			int cellsUsed = 0;
			if (cellsRemaining > 0)
			{
				int childWidthSpec = android.view.View.MeasureSpec.makeMeasureSpec(cellSize * cellsRemaining
					, android.view.View.MeasureSpec.AT_MOST);
				child.measure(childWidthSpec, childHeightSpec);
				int measuredWidth = child.getMeasuredWidth();
				cellsUsed = measuredWidth / cellSize;
				if (measuredWidth % cellSize != 0)
				{
					cellsUsed++;
				}
			}
			[email protected] itemView = child is [email protected]
				 ? ([email protected])child : null;
			bool expandable = !lp.isOverflowButton && itemView != null && itemView.hasText();
			lp.expandable = expandable;
			lp.cellsUsed = cellsUsed;
			int targetWidth = cellsUsed * cellSize;
			child.measure(android.view.View.MeasureSpec.makeMeasureSpec(targetWidth, android.view.View
				.MeasureSpec.EXACTLY), childHeightSpec);
			return cellsUsed;
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:47,代码来源:ActionMenuView.cs

示例9: setupChild

		/// <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
				);
//.........这里部分代码省略.........
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:101,代码来源:GridView.cs

示例10: measureChildView

		protected internal virtual int measureChildView(android.view.View child, int availableWidth
			, int childSpecHeight, int spacing)
		{
			child.measure(android.view.View.MeasureSpec.makeMeasureSpec(availableWidth, android.view.View
				.MeasureSpec.AT_MOST), childSpecHeight);
			availableWidth -= child.getMeasuredWidth();
			availableWidth -= spacing;
			return System.Math.Max(0, availableWidth);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:9,代码来源:AbsActionBarView.cs


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