本文整理汇总了C#中android.getLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:C# android.getLayoutParams方法的具体用法?C# android.getLayoutParams怎么用?C# android.getLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android
的用法示例。
在下文中一共展示了android.getLayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: addView
/// <summary>Adds a child view.</summary>
/// <remarks>
/// Adds a child view. If no layout parameters are already set on the child, the
/// default parameters for this ViewGroup are set on the child.
/// </remarks>
/// <param name="child">the child view to add</param>
/// <param name="index">the position at which to add the child</param>
/// <seealso cref="generateDefaultLayoutParams()">generateDefaultLayoutParams()</seealso>
public virtual void addView(android.view.View child, int index)
{
android.view.ViewGroup.LayoutParams @params = child.getLayoutParams();
if (@params == null)
{
@params = generateDefaultLayoutParams();
if (@params == null)
{
throw new System.ArgumentException("generateDefaultLayoutParams() cannot return null"
);
}
}
addView(child, index, @params);
}
示例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);
}
示例4: 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);
}
示例5: addView
public override void addView(android.view.View child)
{
if (child.getLayoutParams() == null)
{
android.widget.LinearLayout.LayoutParams lp = new android.widget.LinearLayout.LayoutParams
(0, android.view.ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
lp.setMargins(0, 0, 0, 0);
child.setLayoutParams(lp);
}
// Ensure you can navigate to the tab with the keyboard, and you can touch it
child.setFocusable(true);
child.setClickable(true);
base.addView(child);
// TODO: detect this via geometry with a tabwidget listener rather
// than potentially interfere with the view's listener
child.setOnClickListener(new android.widget.TabWidget.TabClickListener(this, getTabCount
() - 1));
child.setOnFocusChangeListener(this);
}
示例6: getDelayForView
/// <summary>
/// Returns the amount of milliseconds by which the specified view's
/// animation must be delayed or offset.
/// </summary>
/// <remarks>
/// Returns the amount of milliseconds by which the specified view's
/// animation must be delayed or offset. Subclasses should override this
/// method to return a suitable value.
/// This implementation returns <code>child animation delay</code>
/// milliseconds where:
/// <pre>
/// child animation delay = child index * delay
/// </pre>
/// The index is retrieved from the
/// <see cref="AnimationParameters">AnimationParameters</see>
/// found in the view's
/// <see cref="android.view.ViewGroup.LayoutParams">android.view.ViewGroup.LayoutParams
/// </see>
/// .
/// </remarks>
/// <param name="view">the view for which to obtain the animation's delay</param>
/// <returns>a delay in milliseconds</returns>
/// <seealso cref="getAnimationForView(android.view.View)">getAnimationForView(android.view.View)
/// </seealso>
/// <seealso cref="getDelay()">getDelay()</seealso>
/// <seealso cref="getTransformedIndex(AnimationParameters)">getTransformedIndex(AnimationParameters)
/// </seealso>
/// <seealso cref="android.view.ViewGroup.LayoutParams">android.view.ViewGroup.LayoutParams
/// </seealso>
protected internal virtual long getDelayForView(android.view.View view)
{
android.view.ViewGroup.LayoutParams lp = view.getLayoutParams();
android.view.animation.LayoutAnimationController.AnimationParameters @params = lp
.layoutAnimationParameters;
if (@params == null)
{
return 0;
}
float delay = mDelay * mAnimation.getDuration();
long viewDelay = (long)(getTransformedIndex(@params) * delay);
float totalDelay = delay * @params.count;
if (mInterpolator == null)
{
mInterpolator = new android.view.animation.LinearInterpolator();
}
float normalizedDelay = viewDelay / totalDelay;
normalizedDelay = mInterpolator.getInterpolation(normalizedDelay);
return (long)(normalizedDelay * totalDelay);
}
示例7: 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);
}
示例8: getNextLocationOffset
internal override int getNextLocationOffset(android.view.View child)
{
return ((android.widget.TableRow.LayoutParams)child.getLayoutParams()).mOffset[android.widget.TableRow
.LayoutParams.LOCATION_NEXT];
}
示例9: 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);
}
示例10: 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);
}
}
示例11: getChildrenSkipCount
internal override int getChildrenSkipCount(android.view.View child, int index)
{
android.widget.TableRow.LayoutParams layoutParams = (android.widget.TableRow.LayoutParams
)child.getLayoutParams();
// when the span is 1 (default), we need to skip 0 child
return layoutParams.span - 1;
}
示例12: transformViewForTransition
internal override void transformViewForTransition(int fromIndex, int toIndex, android.view.View
view, bool animate_1)
{
if (!animate_1)
{
((android.widget.StackView.StackFrame)view).cancelSliderAnimator();
view.setRotationX(0f);
android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
)view.getLayoutParams();
lp.setVerticalOffset(0);
lp.setHorizontalOffset(0);
}
if (fromIndex == -1 && toIndex == getNumActiveViews() - 1)
{
transformViewAtIndex(toIndex, view, false);
view.setVisibility(VISIBLE);
view.setAlpha(1.0f);
}
else
{
if (fromIndex == 0 && toIndex == 1)
{
((android.widget.StackView.StackFrame)view).cancelSliderAnimator();
view.setVisibility(VISIBLE);
int duration = Sharpen.Util.Round(mStackSlider.getDurationForNeutralPosition(mYVelocity
));
android.widget.StackView.StackSlider animationSlider = new android.widget.StackView
.StackSlider(this, mStackSlider);
animationSlider.setView(view);
if (animate_1)
{
android.animation.PropertyValuesHolder slideInY = android.animation.PropertyValuesHolder
.ofFloat("YProgress", 0.0f);
android.animation.PropertyValuesHolder slideInX = android.animation.PropertyValuesHolder
.ofFloat("XProgress", 0.0f);
android.animation.ObjectAnimator slideIn = android.animation.ObjectAnimator.ofPropertyValuesHolder
(animationSlider, slideInX, slideInY);
slideIn.setDuration(duration);
slideIn.setInterpolator(new android.view.animation.LinearInterpolator());
((android.widget.StackView.StackFrame)view).setSliderAnimator(slideIn);
slideIn.start();
}
else
{
animationSlider.setYProgress(0f);
animationSlider.setXProgress(0f);
}
}
else
{
if (fromIndex == 1 && toIndex == 0)
{
((android.widget.StackView.StackFrame)view).cancelSliderAnimator();
int duration = Sharpen.Util.Round(mStackSlider.getDurationForOffscreenPosition(mYVelocity
));
android.widget.StackView.StackSlider animationSlider = new android.widget.StackView
.StackSlider(this, mStackSlider);
animationSlider.setView(view);
if (animate_1)
{
android.animation.PropertyValuesHolder slideOutY = android.animation.PropertyValuesHolder
.ofFloat("YProgress", 1.0f);
android.animation.PropertyValuesHolder slideOutX = android.animation.PropertyValuesHolder
.ofFloat("XProgress", 0.0f);
android.animation.ObjectAnimator slideOut = android.animation.ObjectAnimator.ofPropertyValuesHolder
(animationSlider, slideOutX, slideOutY);
slideOut.setDuration(duration);
slideOut.setInterpolator(new android.view.animation.LinearInterpolator());
((android.widget.StackView.StackFrame)view).setSliderAnimator(slideOut);
slideOut.start();
}
else
{
animationSlider.setYProgress(1.0f);
animationSlider.setXProgress(0f);
}
}
else
{
if (toIndex == 0)
{
view.setAlpha(0.0f);
view.setVisibility(INVISIBLE);
}
else
{
if ((fromIndex == 0 || fromIndex == 1) && toIndex > 1)
{
view.setVisibility(VISIBLE);
view.setAlpha(1.0f);
view.setRotationX(0f);
android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
)view.getLayoutParams();
lp.setVerticalOffset(0);
lp.setHorizontalOffset(0);
}
else
{
if (fromIndex == -1)
{
//.........这里部分代码省略.........
示例13: createOrReuseLayoutParams
internal override android.view.ViewGroup.LayoutParams createOrReuseLayoutParams(android.view.View
v)
{
android.view.ViewGroup.LayoutParams currentLp = v.getLayoutParams();
if (currentLp is android.widget.StackView.LayoutParams)
{
android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
)currentLp;
lp.setHorizontalOffset(0);
lp.setVerticalOffset(0);
lp.width = 0;
lp.width = 0;
return lp;
}
return new android.widget.StackView.LayoutParams(this, v);
}
示例14: 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;
}
示例15: getDelayForView
protected internal override long getDelayForView(android.view.View view)
{
android.view.ViewGroup.LayoutParams lp = view.getLayoutParams();
android.view.animation.GridLayoutAnimationController.AnimationParameters @params =
(android.view.animation.GridLayoutAnimationController.AnimationParameters)lp.layoutAnimationParameters;
if (@params == null)
{
return 0;
}
int column = getTransformedColumnIndex(@params);
int row = getTransformedRowIndex(@params);
int rowsCount = @params.rowsCount;
int columnsCount = @params.columnsCount;
long duration = mAnimation.getDuration();
float columnDelay = mColumnDelay * duration;
float rowDelay = mRowDelay * duration;
float totalDelay;
long viewDelay;
if (mInterpolator == null)
{
mInterpolator = new android.view.animation.LinearInterpolator();
}
switch (mDirectionPriority)
{
case PRIORITY_COLUMN:
{
viewDelay = (long)(row * rowDelay + column * rowsCount * rowDelay);
totalDelay = rowsCount * rowDelay + columnsCount * rowsCount * rowDelay;
break;
}
case PRIORITY_ROW:
{
viewDelay = (long)(column * columnDelay + row * columnsCount * columnDelay);
totalDelay = columnsCount * columnDelay + rowsCount * columnsCount * columnDelay;
break;
}
case PRIORITY_NONE:
default:
{
viewDelay = (long)(column * columnDelay + row * rowDelay);
totalDelay = columnsCount * columnDelay + rowsCount * rowDelay;
break;
}
}
float normalizedDelay = viewDelay / totalDelay;
normalizedDelay = mInterpolator.getInterpolation(normalizedDelay);
return (long)(normalizedDelay * totalDelay);
}