AbsoluteLayoutpublic class AbsoluteLayout extends android.view.ViewGroup A layout that lets you specify exact locations (x/y coordinates) of its
children. Absolute layouts are less flexible and harder to maintain than
other types of layouts without absolute positioning.
XML attributes See {@link
android.R.styleable#ViewGroup ViewGroup Attributes}, {@link
android.R.styleable#View View Attributes} |
Methods Summary |
---|
protected boolean | checkLayoutParams(ViewGroup.LayoutParams p)
return p instanceof AbsoluteLayout.LayoutParams;
| protected ViewGroup.LayoutParams | generateDefaultLayoutParams()Returns a set of layout parameters with a width of
{@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT},
a height of {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
and with the coordinates (0, 0).
return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0);
| public ViewGroup.LayoutParams | generateLayoutParams(android.util.AttributeSet attrs)
return new AbsoluteLayout.LayoutParams(getContext(), attrs);
| protected ViewGroup.LayoutParams | generateLayoutParams(ViewGroup.LayoutParams p)
return new LayoutParams(p);
| protected void | onLayout(boolean changed, int l, int t, int r, int b)
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
if (child.getVisibility() != GONE) {
AbsoluteLayout.LayoutParams lp =
(AbsoluteLayout.LayoutParams) child.getLayoutParams();
int childLeft = mPaddingLeft + lp.x;
int childTop = mPaddingTop + lp.y;
child.layout(childLeft, childTop,
childLeft + child.getMeasuredWidth(),
childTop + child.getMeasuredHeight());
}
}
| protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec)
int count = getChildCount();
int maxHeight = 0;
int maxWidth = 0;
// Find out how big everyone wants to be
measureChildren(widthMeasureSpec, heightMeasureSpec);
// Find rightmost and bottom-most child
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
if (child.getVisibility() != GONE) {
int childRight;
int childBottom;
AbsoluteLayout.LayoutParams lp
= (AbsoluteLayout.LayoutParams) child.getLayoutParams();
childRight = lp.x + child.getMeasuredWidth();
childBottom = lp.y + child.getMeasuredHeight();
maxWidth = Math.max(maxWidth, childRight);
maxHeight = Math.max(maxHeight, childBottom);
}
}
// Account for padding too
maxWidth += mPaddingLeft + mPaddingRight;
maxHeight += mPaddingTop + mPaddingBottom;
// Check against minimum height and width
maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec),
resolveSize(maxHeight, heightMeasureSpec));
|
|