本文整理汇总了C#中android.layout方法的典型用法代码示例。如果您正苦于以下问题:C# android.layout方法的具体用法?C# android.layout怎么用?C# android.layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android
的用法示例。
在下文中一共展示了android.layout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setChildFrame
private void setChildFrame(android.view.View child, int left, int top, int width,
int height)
{
child.layout(left, top, left + width, top + height);
}
示例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);
}
示例3: 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
);
//.........这里部分代码省略.........
示例4: 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);
}
示例5: positionChildInverse
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;
}