Class TableRow

All Implemented Interfaces:
Drawable.Callback, ViewManager, ViewParent

public class TableRow extends LinearLayout

A layout that arranges its children horizontally. A TableRow should always be used as a child of a TableLayout. If a TableRow's parent is not a TableLayout, the TableRow will behave as an horizontal LinearLayout.

The children of a TableRow do not need to specify the layout_width and layout_height attributes in the XML file. TableRow always enforces those values to be respectively ViewGroup.LayoutParams.MATCH_PARENT and ViewGroup.LayoutParams.WRAP_CONTENT.

Also see TableRow.LayoutParams for layout attributes

  • Constructor Details

    • TableRow

      public TableRow(Context context)

      Creates a new TableRow for the given context.

      Parameters:
      context - the application environment
  • Method Details

    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      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 LinearLayout
      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 l, int t, int r, int b)
      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.

      Overrides:
      onLayout in class LinearLayout
      Parameters:
      changed - This is a new size or position for this view
      l - Left position, relative to parent
      t - Top position, relative to parent
      r - Right position, relative to parent
      b - Bottom position, relative to parent
    • getVirtualChildAt

      public View getVirtualChildAt(int i)
    • getVirtualChildCount

      public int getVirtualChildCount()
    • generateDefaultLayoutParams

      @NonNull protected TableRow.LayoutParams generateDefaultLayoutParams()
      Returns a set of layout parameters with a width of ViewGroup.LayoutParams.MATCH_PARENT, a height of ViewGroup.LayoutParams.WRAP_CONTENT and no spanning.
      Overrides:
      generateDefaultLayoutParams in class LinearLayout
      Returns:
      a set of default layout parameters
    • checkLayoutParams

      protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
      Check whether given params fit to this view group.

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

      Overrides:
      checkLayoutParams in class LinearLayout
      Parameters:
      p - layout params to check
      Returns:
      if params matched to this view group
    • generateLayoutParams

      @NonNull protected LinearLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
      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 LinearLayout
      Parameters:
      p - 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