public class XTabLayout
extends android.widget.HorizontalScrollView
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
XTabLayout.Mode |
static interface |
XTabLayout.OnTabSelectedListener
Callback interface invoked when a tab's selection state changes.
|
static class |
XTabLayout.Tab
A tab in this layout.
|
static interface |
XTabLayout.TabGravity |
static class |
XTabLayout.TabLayoutOnPageChangeListener
A
ViewPager.OnPageChangeListener class which contains the
necessary calls back to the provided TabLayout so that the tab position is
kept in sync. |
static class |
XTabLayout.ViewPagerOnTabSelectedListener
A
TabLayout.OnTabSelectedListener class which contains the necessary calls back
to the provided ViewPager so that the tab position is kept in sync. |
android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListenerandroid.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener| 限定符和类型 | 字段和说明 |
|---|---|
static int |
GRAVITY_CENTER
Gravity used to lay out the tabs in the center of the
TabLayout. |
static int |
GRAVITY_FILL
Gravity used to fill the
TabLayout as much as possible. |
static int |
MODE_FIXED
Fixed tabs display all tabs concurrently and are best used with content that benefits from
quick pivots between tabs.
|
static int |
MODE_SCROLLABLE
Scrollable tabs display a subset of tabs at any given moment, and can contain longer tab
labels and a larger number of tabs.
|
CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_OPTICAL_BOUNDS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHEACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, 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, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, 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, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, 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, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, 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, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, 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, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z| 构造器和说明 |
|---|
XTabLayout(android.content.Context context) |
XTabLayout(android.content.Context context,
android.util.AttributeSet attrs) |
XTabLayout(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addOnTabSelectedListener(XTabLayout.OnTabSelectedListener onTabSelectedListener) |
void |
addTab(XTabLayout.Tab tab)
Add a tab to this layout.
|
void |
addTab(XTabLayout.Tab tab,
boolean setSelected)
Add a tab to this layout.
|
void |
addTab(XTabLayout.Tab tab,
int position)
Add a tab to this layout.
|
void |
addTab(XTabLayout.Tab tab,
int position,
boolean setSelected)
Add a tab to this layout.
|
void |
addView(android.view.View child) |
void |
addView(android.view.View child,
int index) |
void |
addView(android.view.View child,
int index,
android.view.ViewGroup.LayoutParams params) |
void |
addView(android.view.View child,
android.view.ViewGroup.LayoutParams params) |
android.widget.FrameLayout.LayoutParams |
generateLayoutParams(android.util.AttributeSet attrs) |
int |
getSelectedTabPosition()
Returns the position of the current selected tab.
|
XTabLayout.Tab |
getTabAt(int index)
Returns the tab at the specified index.
|
int |
getTabCount()
Returns the number of tabs currently registered with the action bar.
|
int |
getTabGravity()
The current gravity used for laying out tabs.
|
int |
getTabMode()
Returns the current mode used by this
TabLayout. |
android.content.res.ColorStateList |
getTabTextColors()
Gets the text colors for the different states (normal, selected) used for the tabs.
|
XTabLayout.Tab |
newTab() |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec) |
void |
removeAllTabs()
Remove all tabs from the action bar and deselect the current tab.
|
void |
removeTab(XTabLayout.Tab tab)
Remove a tab from the layout.
|
void |
removeTabAt(int position)
Remove a tab from the layout.
|
void |
setAllCaps(boolean allCaps)
设置字母是否自动小写转大写
|
void |
setDividerColor(int color)
设置分割线颜色
|
void |
setDividerGravity(int gravity)
设置分割线位置
|
void |
setDividerSize(int width,
int height)
设置分割线长宽
|
void |
setOnTabSelectedListener(XTabLayout.OnTabSelectedListener onTabSelectedListener)
Set the
TabLayout.OnTabSelectedListener that will
handle switching to and from tabs. |
void |
setScrollPosition(int position,
float positionOffset,
boolean updateSelectedText)
Set the scroll position of the tabs.
|
void |
setSelectedTabIndicatorColor(int color)
Sets the tab indicator's color for the currently selected tab.
|
void |
setSelectedTabIndicatorHeight(int height)
Sets the tab indicator's height for the currently selected tab.
|
void |
setTabGravity(int gravity)
Set the gravity to use when laying out the tabs.
|
void |
setTabMode(int mode)
Set the behavior mode for the Tabs in this layout.
|
void |
setTabsFromPagerAdapter(android.support.v4.view.PagerAdapter adapter)
已过时。
Use
setupWithViewPager(ViewPager) to link a TabLayout with a ViewPager
together. When that method is used, the TabLayout will be automatically updated
when the PagerAdapter is changed. |
void |
setTabTextColors(android.content.res.ColorStateList textColor)
Sets the text colors for the different states (normal, selected) used for the tabs.
|
void |
setTabTextColors(int normalColor,
int selectedColor)
Sets the text colors for the different states (normal, selected) used for the tabs.
|
void |
setupWithViewPager(android.support.v4.view.ViewPager viewPager)
The one-stop shop for setting up this
TabLayout with a ViewPager. |
void |
setxTabDisplayNum(int xTabDisplayNum) |
boolean |
shouldDelayChildPressedState() |
arrowScroll, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeScrollDeltaToGetChildRectOnScreen, dispatchKeyEvent, draw, executeKeyEvent, fling, fullScroll, getAccessibilityClassName, getLeftFadingEdgeStrength, getMaxScrollAmount, getRightFadingEdgeStrength, isFillViewport, isSmoothScrollingEnabled, measureChild, measureChildWithMargins, onGenericMotionEvent, onInterceptTouchEvent, onLayout, onOverScrolled, onRequestFocusInDescendants, onRestoreInstanceState, onSaveInstanceState, onSizeChanged, onTouchEvent, pageScroll, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestLayout, scrollTo, setFillViewport, setOverScrollMode, setSmoothScrollingEnabled, smoothScrollBy, smoothScrollTocheckLayoutParams, generateDefaultLayoutParams, generateLayoutParams, getConsiderGoneChildrenWhenMeasuring, getMeasureAllChildren, setForegroundGravity, setMeasureAllChildrenaddChildrenForAccessibility, addFocusables, addStatesFromChildren, addTouchables, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findViewsWithText, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasFocusable, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChildren, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAttachedToWindow, onCreateDrawableState, onDetachedFromWindow, onInterceptHoverEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestSendAccessibilityEvent, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayoutaddFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceLayout, generateViewId, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineProvider, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getResources, getRight, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInTouchMode, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPopulateAccessibilityEvent, onProvideStructure, onProvideVirtualStructure, onRtlPropertiesChanged, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineProvider, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionName, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startNestedScroll, stopNestedScroll, toString, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDrawclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcanResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, requestFitSystemWindowspublic static final int MODE_SCROLLABLE
setTabMode(int),
getTabMode(),
常量字段值public static final int MODE_FIXED
setTabMode(int),
getTabMode(),
常量字段值public static final int GRAVITY_FILL
TabLayout as much as possible. This option only takes effect
when used with MODE_FIXED.setTabGravity(int),
getTabGravity(),
常量字段值public static final int GRAVITY_CENTER
TabLayout.setTabGravity(int),
getTabGravity(),
常量字段值public XTabLayout(android.content.Context context)
public XTabLayout(android.content.Context context,
android.util.AttributeSet attrs)
public XTabLayout(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
public void setDividerSize(int width,
int height)
width - height - 当height =0 时,则分割线长度占满public void setDividerColor(int color)
color - public void setDividerGravity(int gravity)
public void setAllCaps(boolean allCaps)
public void setSelectedTabIndicatorColor(int color)
color - color to use for the indicatorpublic void setSelectedTabIndicatorHeight(int height)
height - height to use for the indicator in pixelspublic void setxTabDisplayNum(int xTabDisplayNum)
public void setScrollPosition(int position,
float positionOffset,
boolean updateSelectedText)
ViewPager.
Calling this method does not update the selected tab, it is only used for drawing purposes.
position - current scroll positionpositionOffset - Value from [0, 1) indicating the offset from position.updateSelectedText - Whether to update the text's selected state.public void addTab(@NonNull
XTabLayout.Tab tab)
tab - Tab to addpublic void addTab(@NonNull
XTabLayout.Tab tab,
int position)
position.
If this is the first tab to be added it will become the selected tab.tab - The tab to addposition - The new position of the tabpublic void addTab(@NonNull
XTabLayout.Tab tab,
boolean setSelected)
tab - Tab to addsetSelected - True if the added tab should become the selected tab.public void addTab(@NonNull
XTabLayout.Tab tab,
int position,
boolean setSelected)
position.tab - The tab to addposition - The new position of the tabsetSelected - True if the added tab should become the selected tab.public void setOnTabSelectedListener(XTabLayout.OnTabSelectedListener onTabSelectedListener)
TabLayout.OnTabSelectedListener that will
handle switching to and from tabs.onTabSelectedListener - Listener to handle tab selection eventspublic void addOnTabSelectedListener(XTabLayout.OnTabSelectedListener onTabSelectedListener)
@NonNull public XTabLayout.Tab newTab()
public int getTabCount()
@Nullable public XTabLayout.Tab getTabAt(int index)
public int getSelectedTabPosition()
-1 if there isn't a selected tab.public void removeTab(XTabLayout.Tab tab)
tab - The tab to removepublic void removeTabAt(int position)
position - Position of the tab to removepublic void removeAllTabs()
public void setTabMode(int mode)
MODE_FIXED: Fixed tabs display all tabs concurrently and are best used
with content that benefits from quick pivots between tabs.MODE_SCROLLABLE: Scrollable tabs display a subset of tabs at any given moment,
and can contain longer tab labels and a larger number of tabs. They are best used for
browsing contexts in touch interfaces when users don’t need to directly compare the tab
labels. This mode is commonly used with a ViewPager.mode - one of MODE_FIXED or MODE_SCROLLABLE.public int getTabMode()
TabLayout.setTabMode(int)public void setTabGravity(int gravity)
gravity - one of GRAVITY_CENTER or GRAVITY_FILL.public int getTabGravity()
GRAVITY_CENTER or GRAVITY_FILL.public void setTabTextColors(@Nullable
android.content.res.ColorStateList textColor)
getTabTextColors()@Nullable public android.content.res.ColorStateList getTabTextColors()
public void setTabTextColors(int normalColor,
int selectedColor)
public void setupWithViewPager(@Nullable
android.support.v4.view.ViewPager viewPager)
TabLayout with a ViewPager.
This method will link the given ViewPager and this TabLayout together so that any changes in one are automatically reflected in the other. This includes adapter changes, scroll state changes, and clicks. The tabs displayed in this layout will be populated from the ViewPager adapter's page titles.
After this method is called, you will not need this method again unless you want to change the linked ViewPager.
If the given ViewPager is non-null, it needs to already have a
PagerAdapter set.
viewPager - The ViewPager to link, or null to clear any previous link.@Deprecated
public void setTabsFromPagerAdapter(@Nullable
android.support.v4.view.PagerAdapter adapter)
setupWithViewPager(ViewPager) to link a TabLayout with a ViewPager
together. When that method is used, the TabLayout will be automatically updated
when the PagerAdapter is changed.public boolean shouldDelayChildPressedState()
shouldDelayChildPressedState 在类中 android.widget.HorizontalScrollViewpublic void addView(android.view.View child)
addView 在类中 android.widget.HorizontalScrollViewpublic void addView(android.view.View child,
int index)
addView 在类中 android.widget.HorizontalScrollViewpublic void addView(android.view.View child,
android.view.ViewGroup.LayoutParams params)
addView 在接口中 android.view.ViewManageraddView 在类中 android.widget.HorizontalScrollViewpublic void addView(android.view.View child,
int index,
android.view.ViewGroup.LayoutParams params)
addView 在类中 android.widget.HorizontalScrollViewprotected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
onMeasure 在类中 android.widget.HorizontalScrollViewpublic android.widget.FrameLayout.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
generateLayoutParams 在类中 android.widget.FrameLayout