FileDocCategorySizeDatePackage
AbsoluteLayout.javaAPI DocAndroid 5.1 API8021Thu Mar 12 22:22:10 GMT 2015android.widget

AbsoluteLayout

public 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}

deprecated
Use {@link android.widget.FrameLayout}, {@link android.widget.RelativeLayout} or a custom layout instead.

Fields Summary
Constructors Summary
public AbsoluteLayout(android.content.Context context)

        this(context, null);
    
public AbsoluteLayout(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public AbsoluteLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public AbsoluteLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);
    
Methods Summary
protected booleancheckLayoutParams(ViewGroup.LayoutParams p)

        return p instanceof AbsoluteLayout.LayoutParams;
    
protected ViewGroup.LayoutParamsgenerateDefaultLayoutParams()
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);
    
protected ViewGroup.LayoutParamsgenerateLayoutParams(ViewGroup.LayoutParams p)

        return new LayoutParams(p);
    
public ViewGroup.LayoutParamsgenerateLayoutParams(android.util.AttributeSet attrs)

        return new AbsoluteLayout.LayoutParams(getContext(), attrs);
    
protected voidonLayout(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 voidonMeasure(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(resolveSizeAndState(maxWidth, widthMeasureSpec, 0),
                resolveSizeAndState(maxHeight, heightMeasureSpec, 0));
    
public booleanshouldDelayChildPressedState()

        return false;