ComponentParentpublic class TableLayout extends ComponentContainer
TableLayout provides interfaces for aligning and arranging the components to display components in a
component with tables. The arrangement mode, the number of rows and columns, and the component's position can be
configured.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
TableLayout.Alignment |
Provides alignment modes for child components in a table layout.
|
static class |
TableLayout.CellSpan |
Stores the span, start cell, and end cell of an element in a table layout.
|
static class |
TableLayout.LayoutConfig |
Provides layout config required in a table layout.
|
static class |
TableLayout.Specification |
Configures column and row attributes of an element in a table layout.
|
Component.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEventComponentContainer.ArrangeListener| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
ALIGN_CONTENTS |
Indicates the margin alignment for child components.
|
static int |
ALIGN_EDGES |
Indicates the boundary alignment for child components.
|
static int |
DEFAULT |
Indicates a table layout parameter that is not defined.
|
ACCESSIBILITY_ADAPTABLE, ACCESSIBILITY_DISABLE, ACCESSIBILITY_ENABLE, AXIS_X, AXIS_Y, CONTOUR_BACKGROUND, CONTOUR_BORDER, CONTOUR_PADDING_BORDER, DEFAULT_SCALE, DRAG_DOWN, DRAG_HORIZONTAL, DRAG_HORIZONTAL_VERTICAL, DRAG_LEFT, DRAG_RIGHT, DRAG_UP, DRAG_VERTICAL, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR, EVENT_TYPE_COMPONENT_CLICKED, EVENT_TYPE_COMPONENT_FOCUSED, EVENT_TYPE_COMPONENT_LONG_CLICKED, EVENT_TYPE_COMPONENT_SCROLLED, EVENT_TYPE_COMPONENT_SELECTED, EVENT_TYPE_COMPONENT_TEXT_UPDATE, EVENT_TYPE_NOTICE, EVENT_TYPE_NOTIFICATION_STATE_UPDATE, EVENT_TYPE_TOAST_SHOW, EVENT_TYPE_WINDOW_STATE_UPDATE, FOCUS_ADAPTABLE, FOCUS_DISABLE, FOCUS_ENABLE, FOCUS_NEXT, FOCUS_PREVIOUS, FOCUS_SIDE_BOTTOM, FOCUS_SIDE_LEFT, FOCUS_SIDE_RIGHT, FOCUS_SIDE_TOP, HIDE, HORIZONTAL, ID_DEFAULT, INHERITED_MODE, INVISIBLE, mBackgroundElement, mCanvasForTaskOverContent, mCanvasForTaskUnderContent, mComponentParent, mContext, mDrawTaskOverContent, mDrawTaskUnderContent, mEstimateSizeListener, mForegroundElement, mForwardHoverListener, mHoverEventListener, mKeyEventListener, mMouseEventListener, mPosition, mRotationEventListener, mShadowElement, mUnconsumedKeyEventListener, OVAL_MODE, OVAL_SCROLL_BAR_MODE, POSITION_X_INDEX, POSITION_Y_INDEX, RECT_MODE, RECT_SCROLL_BAR_MODE, SCROLL_AUTO_STAGE, SCROLL_IDLE_STAGE, SCROLL_NORMAL_STAGE, UNSPECIFIED_SCROLL_BAR_MODE, VERTICAL, VISIBLEFOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener| 构造器 | 说明 |
|---|---|
TableLayout(Context context) |
Default constructor used to create a
TableLayout instance by using the default attribute set and style. |
TableLayout(Context context,
AttrSet attrSet) |
A constructor used to create a
TableLayout instance by using specified attribute set and default
style after the XML file is parsed. |
TableLayout(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
TableLayout instance by using specified attribute set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
ComponentContainer.LayoutConfig |
createLayoutConfig(Context context,
AttrSet attrSet) |
Creates layout parameters using the attribute set of a child component.
|
int |
getAlignmentType() |
Obtains the alignment mode in a table layout.
|
int |
getColumnCount() |
Obtains the number of columns in the table layout.
|
int |
getOrientation() |
Obtains the layout direction of the table layout.
|
int |
getRowCount() |
Obtains the number of rows in the table layout.
|
void |
setAlignmentType(int type) |
Sets the alignment mode in a table layout.
|
void |
setColumnCount(int columnCount) |
Sets the number of columns in the table layout.
|
void |
setOrientation(int orientation) |
Sets the table layout direction.
|
void |
setRowCount(int rowCount) |
Sets the number of rows in the table layout.
|
static TableLayout.Specification |
specification(float weight) |
Returns a specification instance based on the weight of an element.
|
static TableLayout.Specification |
specification(int start) |
Returns a specification instance based on the start position of an element in the table layout.
|
static TableLayout.Specification |
specification(int start,
float weight) |
Returns a specification instance based on the start position of an element in the table layout and the element
weight.
|
static TableLayout.Specification |
specification(int start,
int size) |
Returns a specification instance based on the start position of an element in the table layout and the element
size.
|
static TableLayout.Specification |
specification(int start,
int size,
float weight) |
Returns a specification instance based on the start position of an element in the table layout and the element
size and weight.
|
static TableLayout.Specification |
specification(int start,
int size,
int alignment) |
Obtains specification instances based on the start position of an element in the table layout and the element
size and alignment mode.
|
static TableLayout.Specification |
specification(int start,
int size,
int alignment,
float weight) |
Returns a specification instance based on the start position of an element in the table layout and the size,
alignment mode, and weight of the element.
|
ComponentContainer.LayoutConfig |
verifyLayoutConfig(ComponentContainer.LayoutConfig config) |
Verifies layout parameters based on the current layout type.
|
addDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findFocus, findNextFocusableComponent, findRequestNextFocus, getAccessibility, getAccessibilityDescription, getAlpha, getAltitude, getBackgroundElement, getBaseLine, getBottom, getBoundaryFadeEffectBottomRate, getBoundaryFadeEffectLeftRate, getBoundaryFadeEffectRightRate, getBoundaryFadeEffectTopRate, getCenterZoomFactor, getCentralScrollMode, getClickedListener, getClipEnabled, getComponentDescription, getComponentMinSize, getComponentParent, getComponentPosition, getComponentSize, getComponentStateChangedListener, getComponentTreeObserver, getContentEnable, getContentPosition, getContentPositionX, getContentPositionY, getContext, getContour, getContourRefreshedListener, getCornerMark, getDragAcceptAngle, getDraggedListener, getEditEventListener, getEstimatedHeight, getEstimatedWidth, getFadeEffectBoundaryWidth, getFadeEffectColor, getFocusable, getFocusBorderEnable, getFocusBorderPadding, getFocusBorderRadius, getFocusBorderWidth, getForegroundElement, getForegroundGravity, getForwardHoverListener, getForwardTouchListener, getGesturePriority, getHeight, getHorizontalPadding, getHorizontalPosition, getHoverEventListener, getId, getKeyEventListener, getLayoutConfig, getLayoutDirection, getLayoutDirectionResolved, getLayoutRefreshedListener, getLeft, getLocationOnScreen, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, getMatrix, getMinHeight, getMinWidth, getMode, getModeResolved, getMouseEventListener, getMousePointerStyleListener, getName, getPadding, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPivot, getPivotX, getPivotY, getResourceManager, getRight, getRotation, getRotationEventListener, getRotationSensitivity, getScale, getScaledListener, getScaleX, getScaleY, getScrollbarBackgroundColor, getScrollbarColor, getScrollbarFadingDelay, getScrollbarFadingDuration, getScrollBarMode, getScrollbarRadius, getScrollbarRoundRect, getScrollbarStartAngle, getScrollbarSweepAngle, getScrollbarThickness, getScrollState, getScrollValue, getSelfVisibleRect, getShadowColor, getSpeechEventListener, getTag, getTop, getTouchEventListener, getTransitionSymbol, getTranslation, getTranslationX, getTranslationY, getTranslationZ, getUserNextFocus, getVerticalPadding, getVerticalPosition, getVisibility, getVisibleRectOnScreen, getWidth, getWindowVisibleRect, hasFocus, hasFocusedEffect, hasOverlaps, hideFocusBorder, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onRestoreState, onRtlChanged, onSaveState, performScale, playSound, postLayout, refreshContour, release, removeBindStateChangedListener, removeScrolledListener, requestFocus, requestForceForwardTouchEvent, restoreComponentTreeState, saveComponentTreeState, scrollBy, scrollTo, setAccessibility, setAccessibilityDescription, setAlpha, setAltitude, setBackground, setBindStateChangedListener, setBottom, setBoundaryFadeEffectEnable, setCanAcceptScrollListener, setCenterZoomFactor, setCentralScrollMode, setClickable, setClickedListener, setClipEnabled, setClipToContourEnabled, setComponentDescription, setComponentMinSize, setComponentPosition, setComponentPosition, setComponentSize, setComponentStateChangedListener, setContentEnable, setContentPosition, setContentPositionX, setContentPositionY, setContour, setContourRefreshedListener, setDoubleClickedListener, setDragAcceptAngle, setDraggedListener, setEditEventListener, setEnabled, setEstimatedSize, setEstimateSizeListener, setFadeEffectBoundaryWidth, setFadeEffectColor, setFocusable, setFocusBorderEnable, setFocusBorderPadding, setFocusBorderRadius, setFocusBorderRadius, setFocusBorderWidth, setFocusChangedListener, setFocusedEffect, setForeground, setForegroundGravity, setForwardHoverListener, setForwardTouchListener, setGesturePriority, setHeight, setHorizontalPadding, setHorizontalPosition, setHoverEventListener, setId, setKeyEventListener, setLayoutConfig, setLayoutDirection, setLayoutRefreshedListener, setLeft, setLongClickable, setLongClickedListener, setMarginBottom, setMarginLeft, setMarginRight, setMarginsLeftAndRight, setMarginsTopAndBottom, setMarginTop, setMinHeight, setMinWidth, setMode, setMouseEventListener, setMousePointerStyleListener, setName, setOnDragListener, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRelative, setPaddingRight, setPaddingTop, setPivot, setPivot, setPivotX, setPivotY, setPosition, setPositionX, setPositionY, setPressState, setRight, setRotation, setRotationEventListener, setRotationSensitivity, setScale, setScaledListener, setScaleX, setScaleY, setScrollbarBackgroundColor, setScrollbarColor, setScrollbarFadingDelay, setScrollbarFadingDuration, setScrollbarFadingEnabled, setScrollBarMode, setScrollbarOverlapEnabled, setScrollbarRadius, setScrollbarRoundRect, setScrollbarStartAngle, setScrollbarSweepAngle, setScrollbarThickness, setScrolledListener, setSelected, setShadowColor, setShadowStyle, setSoundEnable, setSpeechEventListener, setTag, setTop, setTouchEventListener, setTouchFocusable, setTransitionSymbol, setTranslation, setTranslationX, setTranslationY, setTranslationZ, setUnconsumedKeyEventListener, setUserNextFocus, setVerticalPadding, setVerticalPosition, setVibrationEffectEnabled, setVisibility, setWidth, showFocusBorder, simulateClick, simulateDrag, startDragAndDrop, subscribeVoiceEvents, unsubscribeVoiceEventsaddComponent, addComponent, addComponent, addComponent, addComponent, dispatchRestoreState, dispatchSaveState, findComponentById, findComponentHolderById, getAutoLayout, getChildCount, getChildIndex, getComponentAt, getComponentTransition, getFocusOrder, getLayoutManager, informConfigurationChanged, isClipToChildBoundsEnabled, isClipToPaddingBoundsEnabled, isTouchEventSplitable, moveChildToFront, onDrag, removeAllComponents, removeComponent, removeComponentAt, removeComponentById, removeComponents, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitablegetComponentParent, postLayoutpublic static final int ALIGN_CONTENTS
public static final int ALIGN_EDGES
public static final int DEFAULT
When creating a specification object instance, if the start position of an element in the table is not
determined, spec(DEFAULT, weight) can be used.
public TableLayout(Context context)
TableLayout instance by using the default attribute set and style.context - Indicates the application context.public TableLayout(Context context, AttrSet attrSet)
TableLayout instance by using specified attribute set and default
style after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public TableLayout(Context context, AttrSet attrSet, String styleName)
TableLayout instance by using specified attribute set and specified style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public void setColumnCount(int columnCount)
If no value is set for the child component, the default number of columns in the parent component is used.
columnCount - Indicates the number of columns.public int getColumnCount()
public void setRowCount(int rowCount)
If no value is set for the child component, the default number of rows in the parent component is used.
rowCount - Indicates the number of rows.public int getRowCount()
public void setOrientation(int orientation)
If this method is not invoked, Component.HORIZONTAL is used by default.
orientation - Indicates the table layout direction. Component.HORIZONTAL indicates that components are
arranged horizontally; Component.VERTICAL indicates that components are arranged vertically.public int getOrientation()
Component.HORIZONTAL indicates that components are arranged
horizontally; Component.VERTICAL indicates that components are arranged vertically.public void setAlignmentType(int type)
If this method is not invoked, ALIGN_CONTENTS is used by default.
type - Indicates the alignment mode in the table layout. ALIGN_EDGES indicates boundary
alignment; ALIGN_CONTENTS indicates margin alignment.public int getAlignmentType()
ALIGN_EDGES if boundary alignment
mode is used; returns ALIGN_CONTENTS if margin alignment mode is used.public static TableLayout.Specification specification(float weight)
DEFAULT.weight - Indicates the element weight. The value cannot be less than 0.public static TableLayout.Specification specification(int start)
1.start - Indicates the start position of the element in the table layout. The value cannot be less than 0.public static TableLayout.Specification specification(int start, float weight)
start - Indicates the start position of the element in the table layout. The value cannot be less than 0.weight - Indicates the element weight. The value cannot be less than 0.public static TableLayout.Specification specification(int start, int size)
start - Indicates the start position of the element in the table layout. The value cannot be less than 0.size - Indicates the element size. The value cannot be less than 0.public static TableLayout.Specification specification(int start, int size, float weight)
start - Indicates the start position of the element in the table layout. The value cannot be less than 0.size - Indicates the element size. The value cannot be less than 0.weight - Indicates the element weight. The value cannot be less than 0.public static TableLayout.Specification specification(int start, int size, int alignment)
start - Indicates the start position of the element in the table layout. The value cannot be less
than 0.size - Indicates the element size. The value cannot be less than 0.alignment - Indicates the alignment mode of an element. ALIGN_EDGES indicates boundary
alignment; ALIGN_CONTENTS indicates margin alignment.public static TableLayout.Specification specification(int start, int size, int alignment, float weight)
start - Indicates the start position of the element in the table layout. The value cannot be less
than 0.size - Indicates the element size. The value cannot be less than 0.alignment - Indicates the alignment mode of an element. ALIGN_EDGES indicates boundary
alignment; ALIGN_CONTENTS indicates margin alignment.weight - Indicates the element weight. The value cannot be less than 0.public ComponentContainer.LayoutConfig verifyLayoutConfig(ComponentContainer.LayoutConfig config)
ComponentContainerverifyLayoutConfig 在接口中 ComponentParentverifyLayoutConfig 在类中 ComponentContainerconfig - Indicates a group of layout parameters to be converted into a ComponentContainer instance.LayoutConfig instance, which represents the layout parameters.public ComponentContainer.LayoutConfig createLayoutConfig(Context context, AttrSet attrSet)
ComponentContainercreateLayoutConfig 在类中 ComponentContainercontext - Indicates the application context.attrSet - Indicates the attribute set.