Added in API level 1

TableRow


open class TableRow : LinearLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.LinearLayout
   ↳ android.widget.TableRow

A layout that arranges its children horizontally. A TableRow should always be used as a child of a android.widget.TableLayout. If a TableRow's parent is not a TableLayout, the TableRow will behave as an horizontal android.widget.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 android.widget.TableLayout.LayoutParams#MATCH_PARENT and android.widget.TableLayout.LayoutParams#WRAP_CONTENT.

Also see android.widget.TableRow.LayoutParams for layout attributes

Summary

Nested classes
open

Set of layout parameters used in table rows.

Inherited XML attributes
Inherited constants
Public constructors
TableRow(context: Context!)

Creates a new TableRow for the given context.

TableRow(context: Context!, attrs: AttributeSet!)

Creates a new TableRow for the given context and with the specified set attributes.

Public methods
open TableRow.LayoutParams!

Returns a new set of layout parameters based on the supplied attributes set.

open CharSequence!

open View!

open Int

open Unit

Register a callback to be invoked when a child is added to or removed from this view.

Protected methods
open Boolean

open LinearLayout.LayoutParams!

Returns a set of layout parameters with a width of android.view.ViewGroup.LayoutParams#MATCH_PARENT, a height of android.view.ViewGroup.LayoutParams#WRAP_CONTENT and no spanning.

open LinearLayout.LayoutParams!

Returns a safe set of layout parameters based on the supplied layout params.

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

Called from layout when this view should assign a size and position to each of its children.

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Measure the view and its content to determine the measured width and the measured height.

Inherited functions
Inherited properties

Public constructors

TableRow

Added in API level 1
TableRow(context: Context!)

Creates a new TableRow for the given context.

Parameters
context Context!: the application environment

TableRow

Added in API level 1
TableRow(
    context: Context!,
    attrs: AttributeSet!)

Creates a new TableRow for the given context and with the specified set attributes.

Parameters
context Context!: the application environment
attrs AttributeSet!: a collection of attributes

Public methods

generateLayoutParams

Added in API level 1
open fun generateLayoutParams(attrs: AttributeSet!): TableRow.LayoutParams!

Returns a new set of layout parameters based on the supplied attributes set.

Parameters
attrs AttributeSet!: the attributes to build the layout parameters from
Return
TableRow.LayoutParams! an instance of android.view.ViewGroup.LayoutParams or one of its descendants

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getVirtualChildAt

Added in API level 1
open fun getVirtualChildAt(i: Int): View!

getVirtualChildCount

Added in API level 1
open fun getVirtualChildCount(): Int

setOnHierarchyChangeListener

Added in API level 1
open fun setOnHierarchyChangeListener(listener: ViewGroup.OnHierarchyChangeListener!): Unit

Register a callback to be invoked when a child is added to or removed from this view.

Parameters
listener ViewGroup.OnHierarchyChangeListener!: the callback to invoke on hierarchy change

Protected methods

checkLayoutParams

Added in API level 1
protected open fun checkLayoutParams(p: ViewGroup.LayoutParams!): Boolean

generateDefaultLayoutParams

Added in API level 1
protected open fun generateDefaultLayoutParams(): LinearLayout.LayoutParams!

Returns a set of layout parameters with a width of android.view.ViewGroup.LayoutParams#MATCH_PARENT, a height of android.view.ViewGroup.LayoutParams#WRAP_CONTENT and no spanning.

Return
LinearLayout.LayoutParams! a set of default layout parameters or null

generateLayoutParams

Added in API level 1
protected open fun generateLayoutParams(p: ViewGroup.LayoutParams!): LinearLayout.LayoutParams!

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 checkLayoutParams(android.view.ViewGroup.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.

Parameters
p ViewGroup.LayoutParams!: The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Return
LinearLayout.LayoutParams! an instance of android.view.ViewGroup.LayoutParams or one of its descendants

onLayout

Added in API level 1
protected open fun onLayout(
    changed: Boolean,
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Unit

Called from layout 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.

Parameters
changed Boolean: 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

onMeasure

Added in API level 1
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit

Measure the view and its content to determine the measured width and the measured height. This method is invoked by 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 setMeasuredDimension(int,int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int,int). Calling the superclass' onMeasure(int,int) 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 onMeasure(int,int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.