Class TableLayout
- All Implemented Interfaces:
Drawable.Callback
,ViewManager
,ViewParent
A layout that arranges its children into rows and columns.
A TableLayout consists of a number of TableRow
objects,
each defining a row (actually, you can have other children, which will be
explained below). TableLayout containers do not display border lines for
their rows, columns, or cells. Each row has zero or more cells; each cell can
hold one View
object. The table has as many columns
as the row with the most cells. A table can leave cells empty. Cells can span
columns, as they can in HTML.
The width of a column is defined by the row with the widest cell in that
column. However, a TableLayout can specify certain columns as shrinkable or
stretchable by calling
setColumnShrinkable()
or setColumnStretchable()
. If
marked as shrinkable, the column width can be shrunk to fit the table into
its parent object. If marked as stretchable, it can expand in width to fit
any extra space. The total width of the table is defined by its parent
container. It is important to remember that a column can be both shrinkable
and stretchable. In such a situation, the column will change its size to
always use up the available space, but never more. Finally, you can hide a
column by calling
setColumnCollapsed()
.
The children of a TableLayout cannot specify the layout_width
attribute. Width is always MATCH_PARENT
. However, the
layout_height
attribute can be defined by a child; default value
is ViewGroup.LayoutParams.WRAP_CONTENT
. If the child
is a TableRow
, then the height is always
ViewGroup.LayoutParams.WRAP_CONTENT
.
Cells must be added to a row in increasing column order, both in code and XML. Column numbers are zero-based. If you don't specify a column number for a child cell, it will autoincrement to the next available column. If you skip a column number, it will be considered an empty cell in that row. See the TableLayout examples in ApiDemos for examples of creating tables in XML.
Although the typical child of a TableLayout is a TableRow, you can actually use any View subclass as a direct child of TableLayout. The View will be displayed as a single row that spans all the table columns.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This set of layout parameters enforces the width of each child to beViewGroup.LayoutParams.MATCH_PARENT
and the height of each child to beViewGroup.LayoutParams.WRAP_CONTENT
, but only if the height is not specified.Nested classes/interfaces inherited from class icyllis.modernui.widget.LinearLayout
LinearLayout.DividerMode, LinearLayout.OrientationMode
Nested classes/interfaces inherited from class icyllis.modernui.view.ViewGroup
ViewGroup.MarginLayoutParams
Nested classes/interfaces inherited from class icyllis.modernui.view.View
View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
-
Field Summary
Fields inherited from class icyllis.modernui.widget.LinearLayout
HORIZONTAL, SHOW_DIVIDER_BEGINNING, SHOW_DIVIDER_END, SHOW_DIVIDER_MIDDLE, SHOW_DIVIDER_NONE, VERTICAL
Fields inherited from class icyllis.modernui.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_DISALLOW_INTERCEPT, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS
Fields inherited from class icyllis.modernui.view.View
ALPHA, BOTTOM, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, LEFT, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mScrollX, mScrollY, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, RIGHT, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TOP, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
-
Constructor Summary
ConstructorDescriptionTableLayout
(Context context) Creates a new TableLayout for the given context. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a child view.void
Adds a child view.void
addView
(View child, int index, ViewGroup.LayoutParams params) Adds a child view with the specified layout parameters.void
addView
(View child, ViewGroup.LayoutParams params) Adds a child view with the specified layout parameters.protected boolean
Check whether given params fit to this view group.protected TableLayout.LayoutParams
Returns a set of layout parameters with a width ofViewGroup.LayoutParams.MATCH_PARENT
, and a height ofViewGroup.LayoutParams.WRAP_CONTENT
.protected LinearLayout.LayoutParams
Returns a safe set of layout parameters based on the supplied layout params.boolean
isColumnCollapsed
(int columnIndex) Returns the collapsed state of the specified column.boolean
isColumnShrinkable
(int columnIndex) Returns whether the specified column is shrinkable or not.boolean
isColumnStretchable
(int columnIndex) Returns whether the specified column is stretchable or not.boolean
Indicates whether all columns are shrinkable or not.boolean
Indicates whether all columns are stretchable or not.protected void
onLayout
(boolean changed, int l, int t, int r, int b) Called fromView.layout(int, int, int, int)
when this view should assign a size and position to each of its children.protected void
onMeasure
(int widthMeasureSpec, int heightMeasureSpec) Measure the view and its content to determine the measured width and the measured height.protected void
onViewAdded
(View child) Called when a new child is added to this ViewGroup.void
Call this when something has changed which has invalidated the layout of this view.void
setColumnCollapsed
(int columnIndex, boolean isCollapsed) Collapses or restores a given column.void
setColumnShrinkable
(int columnIndex, boolean isShrinkable) Makes the given column shrinkable or not.void
setColumnStretchable
(int columnIndex, boolean isStretchable) Makes the given column stretchable or not.void
setShrinkAllColumns
(boolean shrinkAllColumns) Convenience method to mark all columns as shrinkable.void
setStretchAllColumns
(boolean stretchAllColumns) Convenience method to mark all columns as stretchable.Methods inherited from class icyllis.modernui.widget.LinearLayout
getBaseline, getBaselineAlignedChildIndex, getDividerDrawable, getDividerPadding, getDividerWidth, getGravity, getOrientation, getShowDividers, getWeightSum, hasDividerBeforeChildAt, isBaselineAligned, isMeasureWithLargestChildEnabled, onDraw, onRtlPropertiesChanged, setBaselineAligned, setBaselineAlignedChildIndex, setDividerDrawable, setDividerPadding, setGravity, setHorizontalGravity, setMeasureWithLargestChildEnabled, setOrientation, setShowDividers, setVerticalGravity, setWeightSum
Methods inherited from class icyllis.modernui.view.ViewGroup
addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addTransientView, addView, addViewInLayout, addViewInLayout, attachViewToParent, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchTouchEvent, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findViewByPredicateTraversal, findViewTraversal, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildDrawingOrder, getChildMeasureSpec, getChildVisibleRect, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutTransition, getNestedScrollAxes, getTouchscreenBlocksFocus, getTransientView, getTransientViewCount, getTransientViewIndex, hasBooleanFlag, hasFocus, hasTransientState, indexOfChild, internalSetPadding, isChildrenDrawingOrderEnabled, isLayoutSuppressed, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onChildVisibilityChanged, onCreateDrawableState, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onResolvePointerIcon, onSetLayoutParams, onStartNestedScroll, onStopNestedScroll, onViewRemoved, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransitionStart, resetResolvedDrawables, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveTextAlignment, resolveTextDirection, restoreDefaultFocus, setAddStatesFromChildren, setBooleanFlag, setChildrenDrawingOrderEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutTransition, setTouchscreenBlocksFocus, setTransitionGroup, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startViewTransition, suppressLayout, transformPointToViewLocal, updateViewLayout
Methods inherited from class icyllis.modernui.view.View
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, awakenScrollBars, awakenScrollBars, callOnClick, cancelLongPress, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dp, draw, drawableHotspotChanged, findViewById, findViewByPredicate, findViewByPredicateInsideOut, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBottom, getBoundsOnScreen, getBoundsOnScreen, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, handleScrollBarDragging, hasExplicitFocusable, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTranslationTransientState, hasWindowFocus, invalidate, invalidateDrawable, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCancelPendingInputEvents, onCreateContextMenu, onDetachedFromWindow, onDragEvent, onDrawForeground, onDrawScrollBars, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onKeyDown, onKeyShortcut, onKeyUp, onOverScrolled, onResolveDrawables, onScrollChanged, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resolveSize, resolveSizeAndState, scheduleDrawable, scrollBy, scrollTo, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setContextClickable, setDuplicateParentStateEnabled, setElevation, setEnabled, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setFocusedInCluster, setForeground, setForegroundGravity, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotDraw
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface icyllis.modernui.view.ViewParent
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch
-
Constructor Details
-
TableLayout
Creates a new TableLayout for the given context.
- Parameters:
context
- the application environment
-
-
Method Details
-
onViewAdded
Description copied from class:ViewGroup
Called when a new child is added to this ViewGroup. Overrides should always call super.onViewAdded.- Overrides:
onViewAdded
in classViewGroup
- Parameters:
child
- the added child view
-
requestLayout
public void requestLayout()Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (View.isInLayout()
. If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.
- Specified by:
requestLayout
in interfaceViewParent
- Overrides:
requestLayout
in classView
-
isShrinkAllColumns
public boolean isShrinkAllColumns()Indicates whether all columns are shrinkable or not.
- Returns:
- true if all columns are shrinkable, false otherwise
-
setShrinkAllColumns
public void setShrinkAllColumns(boolean shrinkAllColumns) Convenience method to mark all columns as shrinkable.
- Parameters:
shrinkAllColumns
- true to mark all columns shrinkable
-
isStretchAllColumns
public boolean isStretchAllColumns()Indicates whether all columns are stretchable or not.
- Returns:
- true if all columns are stretchable, false otherwise
-
setStretchAllColumns
public void setStretchAllColumns(boolean stretchAllColumns) Convenience method to mark all columns as stretchable.
- Parameters:
stretchAllColumns
- true to mark all columns stretchable
-
setColumnCollapsed
public void setColumnCollapsed(int columnIndex, boolean isCollapsed) Collapses or restores a given column. When collapsed, a column does not appear on screen and the extra space is reclaimed by the other columns. A column is collapsed/restored only when it belongs to a
TableRow
.Calling this method requests a layout operation.
- Parameters:
columnIndex
- the index of the columnisCollapsed
- true if the column must be collapsed, false otherwise
-
isColumnCollapsed
public boolean isColumnCollapsed(int columnIndex) Returns the collapsed state of the specified column.
- Parameters:
columnIndex
- the index of the column- Returns:
- true if the column is collapsed, false otherwise
-
setColumnStretchable
public void setColumnStretchable(int columnIndex, boolean isStretchable) Makes the given column stretchable or not. When stretchable, a column takes up as much as available space as possible in its row.
Calling this method requests a layout operation.
- Parameters:
columnIndex
- the index of the columnisStretchable
- true if the column must be stretchable, false otherwise. Default is false.
-
isColumnStretchable
public boolean isColumnStretchable(int columnIndex) Returns whether the specified column is stretchable or not.
- Parameters:
columnIndex
- the index of the column- Returns:
- true if the column is stretchable, false otherwise
-
setColumnShrinkable
public void setColumnShrinkable(int columnIndex, boolean isShrinkable) Makes the given column shrinkable or not. When a row is too wide, the table can reclaim extra space from shrinkable columns.
Calling this method requests a layout operation.
- Parameters:
columnIndex
- the index of the columnisShrinkable
- true if the column must be shrinkable, false otherwise. Default is false.
-
isColumnShrinkable
public boolean isColumnShrinkable(int columnIndex) Returns whether the specified column is shrinkable or not.
- Parameters:
columnIndex
- the index of the column- Returns:
- true if the column is shrinkable, false otherwise. Default is false.
-
addView
Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.
Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method. -
addView
Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method. -
addView
Adds a child view with the specified layout parameters.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method.- Specified by:
addView
in interfaceViewManager
- Overrides:
addView
in classViewGroup
- Parameters:
child
- the child view to addparams
- the layout parameters to set on the child
-
addView
Adds a child view with the specified layout parameters.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method. -
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 byView.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 anIllegalStateException
, thrown byView.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 classLinearLayout
- Parameters:
widthMeasureSpec
- width measure specification imposed by the parentMeasureSpec
heightMeasureSpec
- height measure specification imposed by the parentMeasureSpec
-
onLayout
protected void onLayout(boolean changed, int l, int t, int r, int b) Called fromView.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 classLinearLayout
- Parameters:
changed
- This is a new size or position for this viewl
- Left position, relative to parentt
- Top position, relative to parentr
- Right position, relative to parentb
- Bottom position, relative to parent
-
generateDefaultLayoutParams
Returns a set of layout parameters with a width ofViewGroup.LayoutParams.MATCH_PARENT
, and a height ofViewGroup.LayoutParams.WRAP_CONTENT
.- Overrides:
generateDefaultLayoutParams
in classLinearLayout
- Returns:
- a set of default layout parameters
-
checkLayoutParams
Check whether given params fit to this view group.See also
ViewGroup.generateLayoutParams(LayoutParams)
See alsoViewGroup.generateDefaultLayoutParams()
- Overrides:
checkLayoutParams
in classLinearLayout
- Parameters:
p
- layout params to check- Returns:
- if params matched to this view group
-
generateLayoutParams
@NonNull protected LinearLayout.LayoutParams generateLayoutParams(@NonNull 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 ofViewGroup.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 classLinearLayout
- 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
-