Class AbsoluteLayout

All Implemented Interfaces:
Drawable.Callback, ViewManager, ViewParent

public class AbsoluteLayout extends 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.
Since:
2.0
  • Constructor Details

    • AbsoluteLayout

      public AbsoluteLayout(Context context)
  • Method Details

    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      Description copied from class: View
      Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

      CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling super.onMeasure() is a valid use.

      The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override the base one to provide better measurements of their content.

      Overrides:
      onMeasure in class View
      Parameters:
      widthMeasureSpec - width measure specification imposed by the parent MeasureSpec
      heightMeasureSpec - height measure specification imposed by the parent MeasureSpec
    • onLayout

      protected void onLayout(boolean changed, int left, int top, int right, int bottom)
      Description copied from class: View
      Called from View.layout(int, int, int, int) when this view should assign a size and position to each of its children.

      Derived classes with children should override this method and call layout on each of their children.

      Specified by:
      onLayout in class ViewGroup
      Parameters:
      changed - This is a new size or position for this view
      left - Left position, relative to parent
      top - Top position, relative to parent
      right - Right position, relative to parent
      bottom - Bottom position, relative to parent
    • generateLayoutParams

      @Nonnull protected ViewGroup.LayoutParams generateLayoutParams(@Nonnull ViewGroup.LayoutParams params)
      Description copied from class: ViewGroup
      Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of ViewGroup.checkLayoutParams(LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.
      Overrides:
      generateLayoutParams in class ViewGroup
      Parameters:
      params - The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
      Returns:
      an instance of ViewGroup.LayoutParams or one of its descendants
    • generateDefaultLayoutParams

      @Nonnull protected ViewGroup.LayoutParams generateDefaultLayoutParams()
      Returns a set of layout parameters with a width of ViewGroup.LayoutParams.WRAP_CONTENT, a height of ViewGroup.LayoutParams.WRAP_CONTENT and with the coordinates (0, 0).
      Overrides:
      generateDefaultLayoutParams in class ViewGroup
      Returns:
      a set of default layout parameters
    • checkLayoutParams

      protected boolean checkLayoutParams(@Nullable ViewGroup.LayoutParams params)
      Description copied from class: ViewGroup
      Check whether given params fit to this view group.

      See also ViewGroup.generateLayoutParams(LayoutParams) See also ViewGroup.generateDefaultLayoutParams()

      Overrides:
      checkLayoutParams in class ViewGroup
      Parameters:
      params - layout params to check
      Returns:
      if params matched to this view group