public class Toolbar extends ViewGroup
A Toolbar is a generalization of action bars
for use
within application layouts. While an action bar is traditionally part of an
Activity's
opaque window decor controlled by the framework,
a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy.
An application may choose to designate a Toolbar as the action bar for an Activity
using the setActionBar()
method.
Toolbar supports a more focused feature set than ActionBar. From start to end, a toolbar may contain a combination of the following optional elements:
minimum height
, if set.Toolbar.LayoutParams
indicates a Gravity
value of
CENTER_HORIZONTAL
the view will attempt to center
within the available space remaining in the Toolbar after all other elements have been
measured.action menu
. The menu of actions will pin to the
end of the Toolbar offering a few
frequent, important or typical actions along with an optional overflow menu for
additional actions. Action buttons are vertically aligned within the Toolbar's
minimum height
, if set.In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.
Modifier and Type | Class and Description |
---|---|
static class |
Toolbar.LayoutParams
Layout information for child views of Toolbars.
|
static interface |
Toolbar.OnMenuItemClickListener
Interface responsible for receiving menu item click events if the items themselves
do not have individual item click listeners.
|
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.DrawingCacheQuality, View.FindViewFlags, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.MeasureSpec, View.OnApplyWindowInsetsListener, 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.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
CLIP_TO_PADDING_MASK, DEBUG_DRAW, FLAG_DISALLOW_INTERCEPT, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_DEFAULT, LAYOUT_MODE_OPTICAL_BOUNDS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
ACCESSIBILITY_CURSOR_POSITION_UNDEFINED, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, 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_ACCESSIBILITY_NODE_PROVIDERS, 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, LAYOUT_DIRECTION_UNDEFINED, mAttributes, mBottom, mCachingFailed, mContext, mCurrentAnimation, mDebugViewAttributes, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NAVIGATION_BAR_TRANSIENT, NAVIGATION_BAR_TRANSLUCENT, NAVIGATION_BAR_TRANSPARENT, NAVIGATION_BAR_UNHIDE, 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, PUBLIC_STATUS_BAR_VISIBILITY_MASK, 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, sPreserveMarginParamsInLayoutParamConversion, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_TRANSIENT, STATUS_BAR_TRANSLUCENT, STATUS_BAR_TRANSPARENT, STATUS_BAR_UNHIDE, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, 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, SYSTEM_UI_TRANSPARENT, 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
Constructor and Description |
---|
Toolbar(Context context) |
Toolbar(Context context,
AttributeSet attrs) |
Toolbar(Context context,
AttributeSet attrs,
int defStyleAttr) |
Toolbar(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes) |
Modifier and Type | Method and Description |
---|---|
boolean |
canShowOverflowMenu() |
protected boolean |
checkLayoutParams(ViewGroup.LayoutParams p) |
void |
collapseActionView()
Collapse a currently expanded action view.
|
void |
dismissPopupMenus()
Dismiss all currently showing popup menus, including overflow or submenus.
|
protected Toolbar.LayoutParams |
generateDefaultLayoutParams()
Returns a set of default layout parameters.
|
Toolbar.LayoutParams |
generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.
|
protected Toolbar.LayoutParams |
generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params.
|
int |
getContentInsetEnd()
Gets the ending content inset for this toolbar.
|
int |
getContentInsetEndWithActions()
Gets the end content inset to use when action buttons are present.
|
int |
getContentInsetLeft()
Gets the left content inset for this toolbar.
|
int |
getContentInsetRight()
Gets the right content inset for this toolbar.
|
int |
getContentInsetStart()
Gets the starting content inset for this toolbar.
|
int |
getContentInsetStartWithNavigation()
Gets the start content inset to use when a navigation button is present.
|
int |
getCurrentContentInsetEnd()
Gets the content inset that will be used on the ending side of the bar in the current
toolbar configuration.
|
int |
getCurrentContentInsetLeft()
Gets the content inset that will be used on the left side of the bar in the current
toolbar configuration.
|
int |
getCurrentContentInsetRight()
Gets the content inset that will be used on the right side of the bar in the current
toolbar configuration.
|
int |
getCurrentContentInsetStart()
Gets the content inset that will be used on the starting side of the bar in the current
toolbar configuration.
|
Drawable |
getLogo()
Return the current logo drawable.
|
CharSequence |
getLogoDescription()
Return the description of the toolbar's logo.
|
Menu |
getMenu()
Return the Menu shown in the toolbar.
|
CharSequence |
getNavigationContentDescription()
Retrieve the currently configured content description for the navigation button view.
|
Drawable |
getNavigationIcon()
Return the current drawable used as the navigation icon.
|
View |
getNavigationView() |
Drawable |
getOverflowIcon()
Return the current drawable used as the overflow icon.
|
int |
getPopupTheme() |
CharSequence |
getSubtitle()
Return the subtitle of this toolbar.
|
CharSequence |
getTitle()
Returns the title of this toolbar.
|
int |
getTitleMarginBottom() |
int |
getTitleMarginEnd() |
int |
getTitleMarginStart() |
int |
getTitleMarginTop() |
DecorToolbar |
getWrapper() |
boolean |
hasExpandedActionView()
Check whether this Toolbar is currently hosting an expanded action view.
|
boolean |
hideOverflowMenu()
Hide the overflow items from the associated menu.
|
void |
inflateMenu(int resId)
Inflate a menu resource into this toolbar.
|
boolean |
isOverflowMenuShowing()
Check whether the overflow menu is currently showing.
|
boolean |
isOverflowMenuShowPending() |
boolean |
isTitleTruncated() |
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b)
Called from layout 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 |
onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
View.onSaveInstanceState() . |
void |
onRtlPropertiesChanged(int layoutDirection)
Called when any RTL property (layout direction or text direction or text alignment) has
been changed.
|
protected Parcelable |
onSaveInstanceState()
Hook allowing a view to generate a representation of its internal state
that can later be used to create a new instance with that same state.
|
protected void |
onSetLayoutParams(View child,
ViewGroup.LayoutParams lp) |
boolean |
onTouchEvent(MotionEvent ev)
Implement this method to handle touch screen motion events.
|
void |
setCollapsible(boolean collapsible)
Force the toolbar to collapse to zero-height during measurement if
it could be considered "empty" (no visible elements with nonzero measured size)
|
void |
setContentInsetEndWithActions(int insetEndWithActions)
Sets the start content inset to use when action buttons are present.
|
void |
setContentInsetsAbsolute(int contentInsetLeft,
int contentInsetRight)
Sets the content insets for this toolbar.
|
void |
setContentInsetsRelative(int contentInsetStart,
int contentInsetEnd)
Sets the content insets for this toolbar relative to layout direction.
|
void |
setContentInsetStartWithNavigation(int insetStartWithNavigation)
Sets the start content inset to use when a navigation button is present.
|
void |
setLogo(Drawable drawable)
Set a logo drawable.
|
void |
setLogo(int resId)
Set a logo drawable from a resource id.
|
void |
setLogoDescription(CharSequence description)
Set a description of the toolbar's logo.
|
void |
setLogoDescription(int resId)
Set a description of the toolbar's logo.
|
void |
setMenu(MenuBuilder menu,
ActionMenuPresenter outerPresenter) |
void |
setMenuCallbacks(MenuPresenter.Callback pcb,
MenuBuilder.Callback mcb)
Must be called before the menu is accessed
|
void |
setNavigationContentDescription(CharSequence description)
Set a content description for the navigation button if one is present.
|
void |
setNavigationContentDescription(int resId)
Set a content description for the navigation button if one is present.
|
void |
setNavigationIcon(Drawable icon)
Set the icon to use for the toolbar's navigation button.
|
void |
setNavigationIcon(int resId)
Set the icon to use for the toolbar's navigation button.
|
void |
setNavigationOnClickListener(View.OnClickListener listener)
Set a listener to respond to navigation events.
|
void |
setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener listener)
Set a listener to respond to menu item click events.
|
void |
setOverflowIcon(Drawable icon)
Set the icon to use for the overflow button.
|
void |
setPopupTheme(int resId)
Specifies the theme to use when inflating popup menus.
|
void |
setSubtitle(CharSequence subtitle)
Set the subtitle of this toolbar.
|
void |
setSubtitle(int resId)
Set the subtitle of this toolbar.
|
void |
setSubtitleTextAppearance(Context context,
int resId)
Sets the text color, size, style, hint color, and highlight color
from the specified TextAppearance resource.
|
void |
setSubtitleTextColor(int color)
Sets the text color of the subtitle, if present.
|
void |
setTitle(CharSequence title)
Set the title of this toolbar.
|
void |
setTitle(int resId)
Set the title of this toolbar.
|
void |
setTitleMargin(int start,
int top,
int end,
int bottom)
Sets the title margin.
|
void |
setTitleMarginBottom(int margin)
Sets the bottom title margin in pixels.
|
void |
setTitleMarginEnd(int margin)
Sets the ending title margin in pixels.
|
void |
setTitleMarginStart(int margin)
Sets the starting title margin in pixels.
|
void |
setTitleMarginTop(int margin)
Sets the top title margin in pixels.
|
void |
setTitleTextAppearance(Context context,
int resId)
Sets the text color, size, style, hint color, and highlight color
from the specified TextAppearance resource.
|
void |
setTitleTextColor(int color)
Sets the text color of the title, if present.
|
boolean |
showOverflowMenu()
Show the overflow items from the associated menu.
|
addChildrenForAccessibility, addFocusables, addStatesFromChildren, addTouchables, addTransientView, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, buildTouchDispatchChildList, canAnimate, captureTransitioningViews, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, createSnapshot, damageChild, damageChildDeferred, damageChildInParent, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchActivityResult, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEventInternal, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, encodeProperties, endViewTransition, findFocus, findNamedViews, findViewByAccessibilityIdTraversal, findViewByPredicateTraversal, findViewsWithText, findViewTraversal, findViewWithTagTraversal, focusableViewAvailable, focusSearch, gatherTransparentRegion, getAccessibilityClassName, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, getTransientView, getTransientViewCount, getTransientViewIndex, hasFocus, hasFocusable, hasHoveredChild, hasTransientState, indexOfChild, internalSetPadding, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isShowingContextMenuWithCoords, isTransformedTouchPointInView, isTransitionGroup, jumpDrawablesToCurrentState, layout, makeOptionalFitsSystemWindows, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAttachedToWindow, onChildVisibilityChanged, onCreateDrawableState, onDebugDraw, onDebugDrawMargins, onInitializeAccessibilityNodeInfoInternal, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onRequestSendAccessibilityEventInternal, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransitionStart, requestTransparentRegion, resetResolvedDrawables, resetResolvedLayoutDirection, resetResolvedPadding, resetResolvedTextAlignment, resetResolvedTextDirection, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveTextAlignment, resolveTextDirection, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, shouldDelayChildPressedState, showContextMenuForChild, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, transformPointToViewLocal, updateViewLayout
addFocusables, addFrameMetricsListener, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, combineMeasuredStates, computeFitSystemWindows, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeOpaqueFlags, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, damageInParent, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, encode, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewWithTag, fitsSystemWindows, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilitySelectionEnd, getAccessibilitySelectionStart, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getBoundsOnScreen, getBoundsOnScreen, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getHotspotBounds, getId, getImportantForAccessibility, getInverseMatrix, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOutlineProvider, getOutsets, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, 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, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowDisplayFrame, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, handleScrollBarDragging, hasNestedScrollingParent, hasOnClickListeners, hasOpaqueScrollbars, hasOverlappingRendering, hasShadow, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeFadingEdgeInternal, initializeScrollbars, initializeScrollbarsInternal, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, invalidateParentCaches, invalidateParentIfNeeded, invalidateParentIfNeededAndWasQuickRejected, isAccessibilityFocused, isAccessibilitySelectionExtendable, isActionableForAccessibility, isActivated, isAssistBlocked, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isForegroundInsidePadding, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInScrollingContainer, isInTouchMode, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutModeOptical, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, measure, mergeDrawableStates, notifySubtreeAccessibilityStateChangedIfNeeded, notifyViewAccessibilityStateChangedIfNeeded, offsetLeftAndRight, offsetTopAndBottom, onActivityResult, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindowInternal, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onFocusLost, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityEventInternal, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onOverScrolled, onPopulateAccessibilityEvent, onPopulateAccessibilityEventInternal, onProvideStructure, onProvideVirtualStructure, onRenderNodeDetached, onResolveDrawables, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performAccessibilityActionInternal, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeFrameMetricsListener, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestKeyboardShortcuts, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetRtlProperties, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventInternal, sendAccessibilityEventUnchecked, sendAccessibilityEventUncheckedInternal, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilitySelection, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAssistBlocked, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOpticalInsets, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealClip, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startActivityForResult, startAnimation, startDrag, startDragAndDrop, startMovingTask, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDisplayListIfDirty, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, requestFitSystemWindows, requestLayout
public Toolbar(Context context)
public Toolbar(Context context, AttributeSet attrs)
public Toolbar(Context context, AttributeSet attrs, int defStyleAttr)
public Toolbar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
public void setPopupTheme(@StyleRes int resId)
resId
- theme used to inflate popup menusgetPopupTheme()
public int getPopupTheme()
setPopupTheme(int)
public void setTitleMargin(int start, int top, int end, int bottom)
start
- the starting title margin in pixelstop
- the top title margin in pixelsend
- the ending title margin in pixelsbottom
- the bottom title margin in pixelsgetTitleMarginStart()
,
getTitleMarginTop()
,
getTitleMarginEnd()
,
getTitleMarginBottom()
public int getTitleMarginStart()
setTitleMarginStart(int)
public void setTitleMarginStart(int margin)
margin
- the starting title margin in pixelsgetTitleMarginStart()
public int getTitleMarginTop()
setTitleMarginTop(int)
public void setTitleMarginTop(int margin)
margin
- the top title margin in pixelsgetTitleMarginTop()
public int getTitleMarginEnd()
setTitleMarginEnd(int)
public void setTitleMarginEnd(int margin)
margin
- the ending title margin in pixelsgetTitleMarginEnd()
public int getTitleMarginBottom()
setTitleMarginBottom(int)
public void setTitleMarginBottom(int margin)
margin
- the bottom title margin in pixelsgetTitleMarginBottom()
public void onRtlPropertiesChanged(int layoutDirection)
View
onRtlPropertiesChanged
in class View
layoutDirection
- the direction of the layoutView.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL
public void setLogo(@DrawableRes int resId)
This drawable should generally take the place of title text. The logo cannot be
clicked. Apps using a logo should also supply a description using
setLogoDescription(int)
.
resId
- ID of a drawable resourcepublic boolean canShowOverflowMenu()
public boolean isOverflowMenuShowing()
public boolean isOverflowMenuShowPending()
public boolean showOverflowMenu()
public boolean hideOverflowMenu()
public void setMenu(MenuBuilder menu, ActionMenuPresenter outerPresenter)
public void dismissPopupMenus()
public boolean isTitleTruncated()
public void setLogo(Drawable drawable)
This drawable should generally take the place of title text. The logo cannot be
clicked. Apps using a logo should also supply a description using
setLogoDescription(int)
.
drawable
- Drawable to use as a logopublic Drawable getLogo()
setLogo(int)
,
setLogo(android.graphics.drawable.Drawable)
public void setLogoDescription(@StringRes int resId)
This description will be used for accessibility or other similar descriptions of the UI.
resId
- String resource idpublic void setLogoDescription(CharSequence description)
This description will be used for accessibility or other similar descriptions of the UI.
description
- Description to setpublic CharSequence getLogoDescription()
public boolean hasExpandedActionView()
An action view may be expanded either directly from the
MenuItem
it belongs to or by user action. If the Toolbar
has an expanded action view it can be collapsed using the collapseActionView()
method.
public void collapseActionView()
An action view may be expanded either directly from the
MenuItem
it belongs to or by user action.
hasExpandedActionView()
public CharSequence getTitle()
public void setTitle(@StringRes int resId)
A title should be used as the anchor for a section of content. It should describe or name the content being viewed.
resId
- Resource ID of a string to set as the titlepublic void setTitle(CharSequence title)
A title should be used as the anchor for a section of content. It should describe or name the content being viewed.
title
- Title to setpublic CharSequence getSubtitle()
public void setSubtitle(@StringRes int resId)
Subtitles should express extended information about the current content.
resId
- String resource IDpublic void setSubtitle(CharSequence subtitle)
Subtitles should express extended information about the current content.
subtitle
- Subtitle to setpublic void setTitleTextAppearance(Context context, @StyleRes int resId)
public void setSubtitleTextAppearance(Context context, @StyleRes int resId)
public void setTitleTextColor(int color)
color
- The new text color in 0xAARRGGBB formatpublic void setSubtitleTextColor(int color)
color
- The new text color in 0xAARRGGBB formatpublic CharSequence getNavigationContentDescription()
public void setNavigationContentDescription(@StringRes int resId)
resId
- Resource ID of a content description string to set, or 0 to
clear the descriptionpublic void setNavigationContentDescription(CharSequence description)
description
- Content description to set, or null
to
clear the content descriptionpublic void setNavigationIcon(@DrawableRes int resId)
The navigation button appears at the start of the toolbar if present. Setting an icon will make the navigation button visible.
If you use a navigation icon you should also set a description for its action using
setNavigationContentDescription(int)
. This is used for accessibility and
tooltips.
resId
- Resource ID of a drawable to setpublic void setNavigationIcon(Drawable icon)
The navigation button appears at the start of the toolbar if present. Setting an icon will make the navigation button visible.
If you use a navigation icon you should also set a description for its action using
setNavigationContentDescription(int)
. This is used for accessibility and
tooltips.
icon
- Drawable to set, may be null to clear the iconpublic Drawable getNavigationIcon()
public void setNavigationOnClickListener(View.OnClickListener listener)
This listener will be called whenever the user clicks the navigation button at the start of the toolbar. An icon must be set for the navigation button to appear.
listener
- Listener to setsetNavigationIcon(android.graphics.drawable.Drawable)
public View getNavigationView()
public Menu getMenu()
Applications that wish to populate the toolbar's menu can do so from here. To use
an XML menu resource, use inflateMenu(int)
.
public void setOverflowIcon(Drawable icon)
icon
- Drawable to set, may be null to clear the iconpublic Drawable getOverflowIcon()
public void inflateMenu(@MenuRes int resId)
Inflate an XML menu resource into this toolbar. Existing items in the menu will not be modified or removed.
resId
- ID of a menu resource to inflatepublic void setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener listener)
This listener will be invoked whenever a user selects a menu item from the action buttons presented at the end of the toolbar or the associated overflow.
listener
- Listener to setpublic void setContentInsetsRelative(int contentInsetStart, int contentInsetEnd)
The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.
contentInsetStart
- Content inset for the toolbar starting edgecontentInsetEnd
- Content inset for the toolbar ending edgesetContentInsetsAbsolute(int, int)
,
getContentInsetStart()
,
getContentInsetEnd()
,
getContentInsetLeft()
,
getContentInsetRight()
public int getContentInsetStart()
The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.
setContentInsetsRelative(int, int)
,
setContentInsetsAbsolute(int, int)
,
getContentInsetEnd()
,
getContentInsetLeft()
,
getContentInsetRight()
public int getContentInsetEnd()
The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.
setContentInsetsRelative(int, int)
,
setContentInsetsAbsolute(int, int)
,
getContentInsetStart()
,
getContentInsetLeft()
,
getContentInsetRight()
public void setContentInsetsAbsolute(int contentInsetLeft, int contentInsetRight)
The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.
contentInsetLeft
- Content inset for the toolbar's left edgecontentInsetRight
- Content inset for the toolbar's right edgesetContentInsetsAbsolute(int, int)
,
getContentInsetStart()
,
getContentInsetEnd()
,
getContentInsetLeft()
,
getContentInsetRight()
public int getContentInsetLeft()
The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.
setContentInsetsRelative(int, int)
,
setContentInsetsAbsolute(int, int)
,
getContentInsetStart()
,
getContentInsetEnd()
,
getContentInsetRight()
public int getContentInsetRight()
The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.
setContentInsetsRelative(int, int)
,
setContentInsetsAbsolute(int, int)
,
getContentInsetStart()
,
getContentInsetEnd()
,
getContentInsetLeft()
public int getContentInsetStartWithNavigation()
Different content insets are often called for when additional buttons are present
in the toolbar, as well as at different toolbar sizes. The larger value of
getContentInsetStart()
and this value will be used during layout.
setContentInsetStartWithNavigation(int)
public void setContentInsetStartWithNavigation(int insetStartWithNavigation)
Different content insets are often called for when additional buttons are present
in the toolbar, as well as at different toolbar sizes. The larger value of
getContentInsetStart()
and this value will be used during layout.
insetStartWithNavigation
- the inset to use when a navigation icon has been set
in pixelsgetContentInsetStartWithNavigation()
public int getContentInsetEndWithActions()
Different content insets are often called for when additional buttons are present
in the toolbar, as well as at different toolbar sizes. The larger value of
getContentInsetEnd()
and this value will be used during layout.
setContentInsetEndWithActions(int)
public void setContentInsetEndWithActions(int insetEndWithActions)
Different content insets are often called for when additional buttons are present
in the toolbar, as well as at different toolbar sizes. The larger value of
getContentInsetEnd()
and this value will be used during layout.
insetEndWithActions
- the inset to use when a menu has been set in pixelssetContentInsetEndWithActions(int)
public int getCurrentContentInsetStart()
getContentInsetStartWithNavigation()
public int getCurrentContentInsetEnd()
getContentInsetEndWithActions()
public int getCurrentContentInsetLeft()
getContentInsetStartWithNavigation()
,
getContentInsetEndWithActions()
public int getCurrentContentInsetRight()
getContentInsetStartWithNavigation()
,
getContentInsetEndWithActions()
protected Parcelable onSaveInstanceState()
View
Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
onSaveInstanceState
in class View
View.onRestoreInstanceState(android.os.Parcelable)
,
View.saveHierarchyState(android.util.SparseArray)
,
View.dispatchSaveInstanceState(android.util.SparseArray)
,
View.setSaveEnabled(boolean)
protected void onRestoreInstanceState(Parcelable state)
View
View.onSaveInstanceState()
. This function will never be called with a
null state.onRestoreInstanceState
in class View
state
- The frozen state that had previously been returned by
View.onSaveInstanceState()
.View.onSaveInstanceState()
,
View.restoreHierarchyState(android.util.SparseArray)
,
View.dispatchRestoreInstanceState(android.util.SparseArray)
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class ViewGroup
View.onAttachedToWindow()
public boolean onTouchEvent(MotionEvent ev)
View
If this method is used to detect click actions, it is recommended that
the actions be performed by implementing and calling
View.performClick()
. This will ensure consistent system behavior,
including:
ACTION_CLICK
when
accessibility features are enabled
onTouchEvent
in class View
ev
- The motion event.protected void onSetLayoutParams(View child, ViewGroup.LayoutParams lp)
onSetLayoutParams
in class ViewGroup
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.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 an
IllegalStateException
, thrown by
View.measure(int, int)
. Calling the superclass'
View.onMeasure(int, int)
is a valid use.
The base class implementation of measure defaults to the background size,
unless a larger size is allowed by the MeasureSpec. Subclasses should
override View.onMeasure(int, int)
to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight()
and
View.getSuggestedMinimumWidth()
).
onMeasure
in class View
widthMeasureSpec
- horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.heightMeasureSpec
- vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.View.getMeasuredWidth()
,
View.getMeasuredHeight()
,
View.setMeasuredDimension(int, int)
,
View.getSuggestedMinimumHeight()
,
View.getSuggestedMinimumWidth()
,
View.MeasureSpec.getMode(int)
,
View.MeasureSpec.getSize(int)
protected void onLayout(boolean changed, int l, int t, int r, int b)
View
public Toolbar.LayoutParams generateLayoutParams(AttributeSet attrs)
ViewGroup
generateLayoutParams
in class ViewGroup
attrs
- the attributes to build the layout parameters fromViewGroup.LayoutParams
or one
of its descendantsprotected Toolbar.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
ViewGroup
ViewGroup.checkLayoutParams(android.view.ViewGroup.LayoutParams)
, this method
is invoked. This method should return a new set of layout params suitable for
this ViewGroup, possibly by copying the appropriate attributes from the
specified set of layout params.generateLayoutParams
in class ViewGroup
p
- The layout parameters to convert into a suitable set of layout parameters
for this ViewGroup.ViewGroup.LayoutParams
or one
of its descendantsprotected Toolbar.LayoutParams generateDefaultLayoutParams()
ViewGroup
ViewGroup.addView(View)
has no layout parameters
already set. If null is returned, an exception is thrown from addView.generateDefaultLayoutParams
in class ViewGroup
protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
checkLayoutParams
in class ViewGroup
public DecorToolbar getWrapper()
public void setCollapsible(boolean collapsible)
public void setMenuCallbacks(MenuPresenter.Callback pcb, MenuBuilder.Callback mcb)