ComponentParentpublic class TabList extends ScrollView
You can create a tab using a TabList object, and then add the new tab to the list using
addTab(ohos.agp.components.TabList.Tab). The layout direction can be either Component.HORIZONTAL or Component.VERTICAL.
The default direction is horizontal.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
class |
TabList.Tab |
Indicates a tab in
TabList. |
static interface |
TabList.TabSelectedListener |
Provides a tab selected listener.
|
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.ArrangeListenerScrollView.ReboundEffectParamsStackLayout.LayoutConfig| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
INDICATOR_BOTTOM_LINE |
Indicates the selection indicator is the bottom line on the tab.
|
static int |
INDICATOR_INVISIBLE |
Indicates the selection indicator is hidden.
|
static int |
INDICATOR_LEFT_LINE |
Indicates the selection indicator is the vertical line on left side of the tab.
|
static int |
INDICATOR_OVAL |
Indicates the selection indicator is the oval background on the tab.
|
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, mArrangeListenerROTATION_SENSITIVITY_DEFAULT, ROTATION_SENSITIVITY_HIGH, ROTATION_SENSITIVITY_LOW| 构造器 | 说明 |
|---|---|
TabList(Context context) |
Default constructor used to create a
TabList instance by using the default attribute set and style. |
TabList(Context context,
AttrSet attrSet) |
A constructor used to create a
TabList instance by using specified attribute set and default
style after the XML file is parsed. |
TabList(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
TabList instance by using specified attribute set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addTab(TabList.Tab tab) |
Adds a tab to the end of the current layout.
|
void |
addTab(TabList.Tab tab,
boolean selected) |
Adds a tab to the end of the current layout and specifies whether it is selected.
|
void |
addTab(TabList.Tab tab,
int pos) |
Adds a tab to the specified position in the current layout.
|
void |
addTab(TabList.Tab tab,
int pos,
boolean selected) |
Adds a tab to a position in the current layout and specifies whether it is selected.
|
void |
addTabSelectedListener(TabList.TabSelectedListener listener) |
Adds the selected listener to a tab in a list.
|
int |
getIndicatorType() |
Obtains the tab indicator type.
|
int |
getNormalTabTextColor() |
Obtains the text color of this tab when it is in the normal state.
|
int |
getOrientation() |
Obtains the layout direction.
|
TabList.Tab |
getSelectedTab() |
Obtains the selected tab in a component.
|
int |
getSelectedTabIndex() |
Obtains the position of the selected tab in a component.
|
int |
getSelectedTabIndicatorColor() |
Obtains the color of the selected tab indicator.
|
int |
getSelectedTabIndicatorHeight() |
Obtains the height of the selected tab indicator.
|
int |
getSelectedTabTextColor() |
Obtains the text color of this tab when it is selected.
|
TabList.Tab |
getTabAt(int pos) |
Obtains the tab in a specified position.
|
int |
getTabCount() |
Obtains the number of tabs in a component.
|
int |
getTabLength() |
Obtains the length of all tabs in a table,which is a non-negative integer.
|
int |
getTabMargin() |
Obtains the margin (in pixels) between two adjacent tabs in a table.
|
int |
getTabTextAlignment() |
Obtains the text alignment mode of a table.
|
int |
getTabTextSize() |
Obtains the text size of a table.
|
boolean |
isFixedMode() |
Obtains whether the fixed mode is enabled.
|
void |
removeAllComponents() |
Removes all tabs from the current component.
|
void |
removeTab(int pos) |
Removes a tab from the specified position.
|
void |
removeTab(TabList.Tab tab) |
Removes a tab.
|
void |
removeTabSelectedListener(TabList.TabSelectedListener listener) |
Removes the listener for selected events from a tab in a layout.
|
void |
selectTab(TabList.Tab tab) |
Selects a tab.
|
void |
selectTabAt(int pos) |
Selects the tab at a specified position in a table.
|
void |
setFixedMode(boolean isFixed) |
Sets whether to fix all tabs and display them at the same time.
|
void |
setIndicatorType(int type) |
Sets the tab indicator type.
|
void |
setOrientation(int orientation) |
Sets the layout direction.
|
void |
setSelectedTabIndicatorColor(int color) |
Sets the color for a selected tab.
|
void |
setSelectedTabIndicatorHeight(int height) |
Sets the height for a selected tab.
|
void |
setTabLength(int length) |
Sets a width or height for all tabs in a layout.
|
void |
setTabMargin(int margin) |
Sets a margin between two tabs in a component.
|
void |
setTabTextAlignment(int alignment) |
Sets the text alignment for all tabs in a component.
|
void |
setTabTextColors(int normal,
int selected) |
Sets the text colors for selected and deselected tabs.
|
void |
setTabTextSize(int size) |
Sets the text size for all tabs in a component.
|
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, removeComponent, removeComponentAt, removeComponentById, removeComponents, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitablegetComponentParent, postLayoutclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddScrollPausePositionX, addScrollPausePositionY, doFling, doFlingX, doFlingY, fluentScrollBy, fluentScrollByX, fluentScrollByY, fluentScrollTo, fluentScrollXTo, fluentScrollYTo, getReboundEffect, getReboundEffectParams, isMatchViewport, setMatchViewportEnabled, setReboundEffect, setReboundEffectParams, setReboundEffectParamscreateLayoutConfig, verifyLayoutConfigpublic static final int INDICATOR_BOTTOM_LINE
public static final int INDICATOR_INVISIBLE
public static final int INDICATOR_LEFT_LINE
public static final int INDICATOR_OVAL
public TabList(Context context)
TabList instance by using the default attribute set and style.context - Indicates the application context.public TabList(Context context, AttrSet attrSet)
TabList 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 TabList(Context context, AttrSet attrSet, String styleName)
TabList 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 addTab(TabList.Tab tab)
tab - Indicates the tab to add.IllegalArgumentException - Throws this exception if the tab value is null.public void addTab(TabList.Tab tab, int pos)
tab - Indicates the tab to add to the specified position.pos - Indicates the position where to add the tab, which must be a non-negative integer less than the
total number of tabs.IllegalArgumentException - Throws this exception if the tab value is null.IllegalArgumentException - Throws this exception if the pos value is less than 0.public void addTab(TabList.Tab tab, boolean selected)
tab - Indicates the tab to add.selected - Indicates whether the tab is selected. true indicates the tab is selected; false
indicates otherwise.IllegalArgumentException - Throws this exception if the tab value is null.public void addTab(TabList.Tab tab, int pos, boolean selected)
tab - Indicates the tab to add.pos - Indicates the position where to add the tab.selected - Indicates whether the tab is selected. true indicates that the tab is selected; and
false indicates the opposite.IllegalArgumentException - Throws this exception if the tab value is null.IllegalArgumentException - Throws this exception if the pos value is less than 0.public void removeTab(TabList.Tab tab)
tab - Indicates the tab to remove.IllegalArgumentException - Throws this exception if the parameter value is null.public void removeTab(int pos)
pos - Indicates the position of the tab to remove. The value must be a non-negative integer less than the
total number of the tabs.IllegalArgumentException - Throws this exception if the pos value is less than 0
or no tab on this position.public void removeAllComponents()
public TabList.Tab getTabAt(int pos)
This method returns the tab in the specified position, or a null pointer if the position is invalid.
pos - Indicates the position of the tab. The value must be a non-negative integer.IllegalArgumentException - Throws this exception if the parameter value is less than 0.public void selectTabAt(int pos)
pos - Indicates the specified position in the table. The value must be a non-negative integer.IllegalArgumentException - Throws this exception if the parameter value is less than 0
or no tab on this position.public void selectTab(TabList.Tab tab)
The previously selected tab is automatically deselected if it belongs to the current component.
tab - Indicates the tab to select.IllegalArgumentException - Throws this exception if the parameter value is null.public TabList.Tab getSelectedTab()
public int getSelectedTabIndex()
public int getTabCount()
public void setTabTextColors(int normal,
int selected)
normal - Indicates the text color for the deselected tabs.selected - Indicates the text color for the selected tabs.public int getNormalTabTextColor()
public int getSelectedTabTextColor()
public void setTabTextSize(int size)
size - Indicates the text size set for all tabs. The value must be a positive integer.IllegalArgumentException - Throws this exception if the parameter value is less than 0public int getTabTextSize()
public int getTabTextAlignment()
TextAlignment.LEFT: left alignedTextAlignment.RIGHT: right alignedTextAlignment.HORIZONTAL_CENTER: horizontally centeredTextAlignment.TOP: top alignedTextAlignment.VERTICAL_CENTER: vertically centeredTextAlignment.BOTTOM: bottom alignedTextAlignment.CENTER: horizontally and vertically centeredTextAlignment.START: start alignedTextAlignment.END: end alignedpublic int getTabLength()
public int getTabMargin()
public void setTabTextAlignment(int alignment)
alignment - Indicates the text alignment of tabs.
TextAlignment.LEFT: Left alignment;TextAlignment.RIGHT: Right alignment;TextAlignment.HORIZONTAL_CENTER: Horizontally centered;TextAlignment.TOP: Top alignment;TextAlignment.VERTICAL_CENTER: Vertically centered;TextAlignment.BOTTOM: Bottom alignment;TextAlignment.CENTER: Horizontally and vertically centered;TextAlignment.START: Start alignment;TextAlignment.END: End alignment.IllegalArgumentException - Throws the exception if the parameter value
doesn't corresponds to TextAlignment.public void setTabLength(int length)
The tab width is set in a horizontal layout, while the tab height is set in a vertical layout. The value must be a non-negative integer.
length - Indicates the tab width or height.public void setTabMargin(int margin)
margin - Indicates the margin between two tabs. The value must be a non-negative integer.IllegalArgumentException - Throws this exception if the parameter value is less than 0.public void setFixedMode(boolean isFixed)
If the fixed mode is disabled, the width or height of the layout equals to the total width or height of all tabs in it. If the fixed mode is enabled, the width or height of the layout is fixed and each tab in it has the same width or height.
isFixed - Indicates whether tabs are fixed in the layout. true indicates that all tabs are fixed,
and false indicates the opposite.public boolean isFixedMode()
true if the fixed mode is enabled; returns false otherwise.setFixedMode(boolean)public void setSelectedTabIndicatorColor(int color)
color - Indicates the color of the selected tab, which can be a customized color, or
specified by a constant of Color.public int getSelectedTabIndicatorColor()
public void setSelectedTabIndicatorHeight(int height)
height - Indicates the height of the selected tab. The value must be a non-negative integer.IllegalArgumentException - Throws this exception if the parameter value is less than 0.public int getSelectedTabIndicatorHeight()
public void setOrientation(int orientation)
orientation - Indicates the layout direction, which can be Component.HORIZONTAL or Component.VERTICAL.public int getOrientation()
public void setIndicatorType(int type)
type - Indicates the tab indicator type, which can be INDICATOR_INVISIBLE,
INDICATOR_BOTTOM_LINE, INDICATOR_LEFT_LINE, or INDICATOR_OVAL.public int getIndicatorType()
INDICATOR_INVISIBLE,
INDICATOR_BOTTOM_LINE, INDICATOR_LEFT_LINE, or INDICATOR_OVAL.public void addTabSelectedListener(TabList.TabSelectedListener listener)
listener - Indicates the listener.public void removeTabSelectedListener(TabList.TabSelectedListener listener)
listener - Indicates the listener to remove.