public class Toolbar
extends android.view.ViewGroup
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.
|
android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener
android.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
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_CACHE
ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, 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_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
Constructor and Description |
---|
Toolbar(android.content.Context context) |
Toolbar(android.content.Context context,
android.util.AttributeSet attrs) |
Toolbar(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr) |
Modifier and Type | Method and Description |
---|---|
boolean |
canShowOverflowMenu() |
protected boolean |
checkLayoutParams(android.view.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() |
Toolbar.LayoutParams |
generateLayoutParams(android.util.AttributeSet attrs) |
protected Toolbar.LayoutParams |
generateLayoutParams(android.view.ViewGroup.LayoutParams p) |
int |
getContentInsetEnd()
Get the ending content inset for this toolbar.
|
int |
getContentInsetLeft()
Get the left content inset for this toolbar.
|
int |
getContentInsetRight()
Get the right content inset for this toolbar.
|
int |
getContentInsetStart()
Get the starting content inset for this toolbar.
|
android.graphics.drawable.Drawable |
getLogo()
Return the current logo drawable.
|
java.lang.CharSequence |
getLogoDescription()
Return the description of the toolbar's logo.
|
android.view.Menu |
getMenu()
Return the Menu shown in the toolbar.
|
java.lang.CharSequence |
getNavigationContentDescription()
Retrieve the currently configured content description for the navigation button view.
|
android.graphics.drawable.Drawable |
getNavigationIcon()
Return the current drawable used as the navigation icon.
|
int |
getPopupTheme() |
java.lang.CharSequence |
getSubtitle()
Return the subtitle of this toolbar.
|
java.lang.CharSequence |
getTitle()
Returns the title of this toolbar.
|
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() |
boolean |
onHoverEvent(android.view.MotionEvent ev) |
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b) |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec) |
protected void |
onRestoreInstanceState(android.os.Parcelable state) |
void |
onRtlPropertiesChanged(int layoutDirection) |
protected android.os.Parcelable |
onSaveInstanceState() |
boolean |
onTouchEvent(android.view.MotionEvent ev) |
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 |
setContentInsetsAbsolute(int contentInsetLeft,
int contentInsetRight)
Set the content insets for this toolbar.
|
void |
setContentInsetsRelative(int contentInsetStart,
int contentInsetEnd)
Set the content insets for this toolbar relative to layout direction.
|
void |
setLogo(android.graphics.drawable.Drawable drawable)
Set a logo drawable.
|
void |
setLogo(int resId)
Set a logo drawable from a resource id.
|
void |
setLogoDescription(java.lang.CharSequence description)
Set a description of the toolbar's logo.
|
void |
setLogoDescription(int resId)
Set a description of the toolbar's logo.
|
void |
setMenuCallbacks(android.support.v7.view.menu.MenuPresenter.Callback pcb,
android.support.v7.view.menu.MenuBuilder.Callback mcb)
Must be called before the menu is accessed
|
void |
setMinimumHeight(int minHeight) |
void |
setNavigationContentDescription(java.lang.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(android.graphics.drawable.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(android.view.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 |
setPopupTheme(int resId)
Specifies the theme to use when inflating popup menus.
|
void |
setSubtitle(java.lang.CharSequence subtitle)
Set the subtitle of this toolbar.
|
void |
setSubtitle(int resId)
Set the subtitle of this toolbar.
|
void |
setSubtitleTextAppearance(android.content.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(java.lang.CharSequence title)
Set the title of this toolbar.
|
void |
setTitle(int resId)
Set the title of this toolbar.
|
void |
setTitleTextAppearance(android.content.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, addView, addView, addView, addView, 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, dispatchKeyEvent, 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, getAccessibilityClassName, 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, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAttachedToWindow, onCreateDrawableState, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, 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, updateViewLayout
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchFinishTemporaryDetach, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, dispatchStartTemporaryDetach, draw, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, 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, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, 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, getPointerIcon, 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, 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, isTemporarilyDetached, 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, onGenericMotionEvent, onHoverChanged, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onOverScrolled, onPopulateAccessibilityEvent, onProvideStructure, onProvideVirtualStructure, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, 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, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, 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, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionName, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, unscheduleDrawable, unscheduleDrawable, 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(android.content.Context context)
public Toolbar(android.content.Context context, android.util.AttributeSet attrs)
public Toolbar(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)
public void setPopupTheme(int resId)
resId
- theme used to inflate popup menusgetPopupTheme()
public int getPopupTheme()
setPopupTheme(int)
public void onRtlPropertiesChanged(int layoutDirection)
onRtlPropertiesChanged
in class android.view.View
public void setLogo(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 dismissPopupMenus()
public boolean isTitleTruncated()
public void setLogo(android.graphics.drawable.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 android.graphics.drawable.Drawable getLogo()
setLogo(int)
,
setLogo(android.graphics.drawable.Drawable)
public void setLogoDescription(int resId)
This description will be used for accessibility or other similar descriptions of the UI.
resId
- String resource idpublic void setLogoDescription(java.lang.CharSequence description)
This description will be used for accessibility or other similar descriptions of the UI.
description
- Description to setpublic java.lang.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 java.lang.CharSequence getTitle()
public void setTitle(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(java.lang.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 java.lang.CharSequence getSubtitle()
public void setSubtitle(int resId)
Subtitles should express extended information about the current content.
resId
- String resource IDpublic void setSubtitle(java.lang.CharSequence subtitle)
Subtitles should express extended information about the current content.
subtitle
- Subtitle to setpublic void setTitleTextAppearance(android.content.Context context, int resId)
public void setSubtitleTextAppearance(android.content.Context context, 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 format@Nullable public java.lang.CharSequence getNavigationContentDescription()
public void setNavigationContentDescription(int resId)
resId
- Resource ID of a content description string to set, or 0 to clear the
descriptionpublic void setNavigationContentDescription(@Nullable java.lang.CharSequence description)
description
- Content description to set, or null
to clear the content
descriptionpublic void setNavigationIcon(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(@Nullable android.graphics.drawable.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 icon@Nullable public android.graphics.drawable.Drawable getNavigationIcon()
public void setNavigationOnClickListener(android.view.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 android.view.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 inflateMenu(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()
protected android.os.Parcelable onSaveInstanceState()
onSaveInstanceState
in class android.view.View
protected void onRestoreInstanceState(android.os.Parcelable state)
onRestoreInstanceState
in class android.view.View
protected void onDetachedFromWindow()
onDetachedFromWindow
in class android.view.ViewGroup
public boolean onTouchEvent(android.view.MotionEvent ev)
onTouchEvent
in class android.view.View
public boolean onHoverEvent(android.view.MotionEvent ev)
onHoverEvent
in class android.view.View
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
onMeasure
in class android.view.View
protected void onLayout(boolean changed, int l, int t, int r, int b)
onLayout
in class android.view.ViewGroup
public Toolbar.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
generateLayoutParams
in class android.view.ViewGroup
protected Toolbar.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p)
generateLayoutParams
in class android.view.ViewGroup
protected Toolbar.LayoutParams generateDefaultLayoutParams()
generateDefaultLayoutParams
in class android.view.ViewGroup
protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p)
checkLayoutParams
in class android.view.ViewGroup
public void setCollapsible(boolean collapsible)
public void setMenuCallbacks(android.support.v7.view.menu.MenuPresenter.Callback pcb, android.support.v7.view.menu.MenuBuilder.Callback mcb)
public void setMinimumHeight(int minHeight)
setMinimumHeight
in class android.view.View