public class CollapsingToolbarLayout extends FrameLayout
Toolbar
which implements a collapsing app bar.
It is designed to be used as a direct child of a AppBarLayout
.
CollapsingToolbarLayout contains the following features:
setTitle(CharSequence)
. The title appearance can be tweaked via the
collapsedTextAppearance
and expandedTextAppearance
attributes.
setContentScrim(Drawable)
.
setStatusBarScrim(Drawable)
. This only works
on LOLLIPOP
devices when we set to fit system
windows.
CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PARALLAX
and
CollapsingToolbarLayout.LayoutParams.setParallaxMultiplier(float)
.
Toolbar
to be fixed in place even though this layout is
moving. See CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PIN
.
Do not manually add views to the Toolbar at run time. We will add a 'dummy view' to the Toolbar which allows us to work out the available space for the title. This can interfere with any views which you add.
Modifier and Type | Class and Description |
---|---|
static class |
CollapsingToolbarLayout.LayoutParams |
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 |
---|
CollapsingToolbarLayout(Context context) |
CollapsingToolbarLayout(Context context,
AttributeSet attrs) |
CollapsingToolbarLayout(Context context,
AttributeSet attrs,
int defStyleAttr) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkLayoutParams(ViewGroup.LayoutParams p) |
void |
draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
|
protected void |
drawableStateChanged()
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
|
protected boolean |
drawChild(Canvas canvas,
View child,
long drawingTime)
Draw one child of this View Group.
|
protected CollapsingToolbarLayout.LayoutParams |
generateDefaultLayoutParams()
Returns a set of layout parameters with a width of
ViewGroup.LayoutParams.MATCH_PARENT ,
and a height of ViewGroup.LayoutParams.MATCH_PARENT . |
FrameLayout.LayoutParams |
generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.
|
protected FrameLayout.LayoutParams |
generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params.
|
int |
getCollapsedTitleGravity()
Returns the horizontal and vertical alignment for title when collapsed.
|
Typeface |
getCollapsedTitleTypeface()
Returns the typeface used for the collapsed title.
|
Drawable |
getContentScrim()
Returns the drawable which is used for the foreground scrim.
|
int |
getExpandedTitleGravity()
Returns the horizontal and vertical alignment for title when expanded.
|
int |
getExpandedTitleMarginBottom() |
int |
getExpandedTitleMarginEnd() |
int |
getExpandedTitleMarginStart() |
int |
getExpandedTitleMarginTop() |
Typeface |
getExpandedTitleTypeface()
Returns the typeface used for the expanded title.
|
long |
getScrimAnimationDuration()
Returns the duration in milliseconds used for scrim visibility animations.
|
int |
getScrimVisibleHeightTrigger()
Returns the amount of visible height in pixels used to define when to trigger a scrim
visibility change.
|
Drawable |
getStatusBarScrim()
Returns the drawable which is used for the status bar scrim.
|
CharSequence |
getTitle()
Returns the title currently being displayed by this view.
|
boolean |
isTitleEnabled()
Returns whether this view is currently displaying its own title.
|
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
protected void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom)
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 |
onSizeChanged(int w,
int h,
int oldw,
int oldh)
This is called during layout when the size of this view has changed.
|
void |
setCollapsedTitleGravity(int gravity)
Sets the horizontal alignment of the collapsed title and the vertical gravity that will
be used when there is extra space in the collapsed bounds beyond what is required for
the title itself.
|
void |
setCollapsedTitleTextAppearance(int resId)
Sets the text color and size for the collapsed title from the specified
TextAppearance resource.
|
void |
setCollapsedTitleTextColor(ColorStateList colors)
Sets the text colors of the collapsed title.
|
void |
setCollapsedTitleTextColor(int color)
Sets the text color of the collapsed title.
|
void |
setCollapsedTitleTypeface(Typeface typeface)
Set the typeface to use for the collapsed title.
|
void |
setContentScrim(Drawable drawable)
Set the drawable to use for the content scrim from resources.
|
void |
setContentScrimColor(int color)
Set the color to use for the content scrim.
|
void |
setContentScrimResource(int resId)
Set the drawable to use for the content scrim from resources.
|
void |
setExpandedTitleColor(int color)
Sets the text color of the expanded title.
|
void |
setExpandedTitleGravity(int gravity)
Sets the horizontal alignment of the expanded title and the vertical gravity that will
be used when there is extra space in the expanded bounds beyond what is required for
the title itself.
|
void |
setExpandedTitleMargin(int start,
int top,
int end,
int bottom)
Sets the expanded title margins.
|
void |
setExpandedTitleMarginBottom(int margin)
Sets the bottom expanded title margin in pixels.
|
void |
setExpandedTitleMarginEnd(int margin)
Sets the ending expanded title margin in pixels.
|
void |
setExpandedTitleMarginStart(int margin)
Sets the starting expanded title margin in pixels.
|
void |
setExpandedTitleMarginTop(int margin)
Sets the top expanded title margin in pixels.
|
void |
setExpandedTitleTextAppearance(int resId)
Sets the text color and size for the expanded title from the specified
TextAppearance resource.
|
void |
setExpandedTitleTextColor(ColorStateList colors)
Sets the text colors of the expanded title.
|
void |
setExpandedTitleTypeface(Typeface typeface)
Set the typeface to use for the expanded title.
|
void |
setScrimAnimationDuration(long duration)
Set the duration used for scrim visibility animations.
|
void |
setScrimsShown(boolean shown)
Set whether the content scrim and/or status bar scrim should be shown or not.
|
void |
setScrimsShown(boolean shown,
boolean animate)
Set whether the content scrim and/or status bar scrim should be shown or not.
|
void |
setScrimVisibleHeightTrigger(int height)
Set the amount of visible height in pixels used to define when to trigger a scrim
visibility change.
|
void |
setStatusBarScrim(Drawable drawable)
Set the drawable to use for the status bar scrim from resources.
|
void |
setStatusBarScrimColor(int color)
Set the color to use for the status bar scrim.
|
void |
setStatusBarScrimResource(int resId)
Set the drawable to use for the content scrim from resources.
|
void |
setTitle(CharSequence title)
Sets the title to be displayed by this view, if enabled.
|
void |
setTitleEnabled(boolean enabled)
Sets whether this view should display its own title.
|
void |
setVisibility(int visibility)
Set the visibility state of this view.
|
protected boolean |
verifyDrawable(Drawable who)
If your view subclass is displaying its own Drawable objects, it should
override this function and return true for any Drawable it is
displaying.
|
encodeProperties, getAccessibilityClassName, getConsiderGoneChildrenWhenMeasuring, getMeasureAllChildren, setForegroundGravity, setMeasureAllChildren, shouldDelayChildPressedState
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, endViewTransition, findFocus, findNamedViews, findViewByAccessibilityIdTraversal, findViewByPredicateTraversal, findViewsWithText, findViewTraversal, findViewWithTagTraversal, focusableViewAvailable, focusSearch, gatherTransparentRegion, 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, onChildVisibilityChanged, onCreateDrawableState, onDebugDraw, onDebugDrawMargins, onInitializeAccessibilityNodeInfoInternal, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onRequestSendAccessibilityEventInternal, onResolvePointerIcon, onSetLayoutParams, 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, 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, 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, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, 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, 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, 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, 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 CollapsingToolbarLayout(Context context)
public CollapsingToolbarLayout(Context context, AttributeSet attrs)
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr)
protected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class ViewGroup
View.onDetachedFromWindow()
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class ViewGroup
View.onAttachedToWindow()
public void draw(Canvas canvas)
View
View.onDraw(android.graphics.Canvas)
instead of overriding this method.
If you do need to override this method, call the superclass version.protected boolean drawChild(Canvas canvas, View child, long drawingTime)
ViewGroup
protected void onSizeChanged(int w, int h, int oldw, int oldh)
View
onSizeChanged
in class View
w
- Current width of this view.h
- Current height of this view.oldw
- Old width of this view.oldh
- Old height of this view.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 FrameLayout
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 left, int top, int right, int bottom)
View
onLayout
in class FrameLayout
changed
- This is a new size or position for this viewleft
- Left position, relative to parenttop
- Top position, relative to parentright
- Right position, relative to parentbottom
- Bottom position, relative to parentpublic void setTitle(@Nullable CharSequence title)
setTitleEnabled(boolean)
,
getTitle()
@Nullable public CharSequence getTitle()
null
.public void setTitleEnabled(boolean enabled)
The title displayed by this view will shrink and grow based on the scroll offset.
setTitle(CharSequence)
,
isTitleEnabled()
public boolean isTitleEnabled()
setTitleEnabled(boolean)
public void setScrimsShown(boolean shown)
shown
- whether the scrims should be showngetStatusBarScrim()
,
getContentScrim()
public void setScrimsShown(boolean shown, boolean animate)
shown
- whether the scrims should be shownanimate
- whether to animate the visibility changegetStatusBarScrim()
,
getContentScrim()
public void setContentScrim(@Nullable Drawable drawable)
drawable
- the drawable to displaygetContentScrim()
public void setContentScrimColor(int color)
color
- the color to displaygetContentScrim()
public void setContentScrimResource(@DrawableRes int resId)
resId
- drawable resource idgetContentScrim()
@Nullable public Drawable getContentScrim()
setContentScrim(Drawable)
public void setStatusBarScrim(@Nullable Drawable drawable)
This scrim is only shown when we have been given a top system inset.
drawable
- the drawable to displaygetStatusBarScrim()
protected void drawableStateChanged()
View
If the View has a StateListAnimator, it will also be called to run necessary state change animations.
Be sure to call through to the superclass when overriding this function.
drawableStateChanged
in class ViewGroup
Drawable.setState(int[])
protected boolean verifyDrawable(Drawable who)
View
Be sure to call through to the super class when overriding this function.
verifyDrawable
in class View
who
- The Drawable to verify. Return true if it is one you are
displaying, else return the result of calling through to the
super class.View.unscheduleDrawable(android.graphics.drawable.Drawable)
,
View.drawableStateChanged()
public void setVisibility(int visibility)
View
setVisibility
in class View
visibility
- One of View.VISIBLE
, View.INVISIBLE
, or View.GONE
.public void setStatusBarScrimColor(int color)
This scrim is only shown when we have been given a top system inset.
color
- the color to displaygetStatusBarScrim()
public void setStatusBarScrimResource(@DrawableRes int resId)
resId
- drawable resource idgetStatusBarScrim()
@Nullable public Drawable getStatusBarScrim()
setStatusBarScrim(Drawable)
public void setCollapsedTitleTextAppearance(@StyleRes int resId)
public void setCollapsedTitleTextColor(int color)
color
- The new text color in ARGB formatpublic void setCollapsedTitleTextColor(@NonNull ColorStateList colors)
colors
- ColorStateList containing the new text colorspublic void setCollapsedTitleGravity(int gravity)
public int getCollapsedTitleGravity()
public void setExpandedTitleTextAppearance(@StyleRes int resId)
public void setExpandedTitleColor(int color)
color
- The new text color in ARGB formatpublic void setExpandedTitleTextColor(@NonNull ColorStateList colors)
colors
- ColorStateList containing the new text colorspublic void setExpandedTitleGravity(int gravity)
public int getExpandedTitleGravity()
public void setCollapsedTitleTypeface(@Nullable Typeface typeface)
typeface
- typeface to use, or null
to use the default.@NonNull public Typeface getCollapsedTitleTypeface()
public void setExpandedTitleTypeface(@Nullable Typeface typeface)
typeface
- typeface to use, or null
to use the default.@NonNull public Typeface getExpandedTitleTypeface()
public void setExpandedTitleMargin(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 pixelsgetExpandedTitleMarginStart()
,
getExpandedTitleMarginTop()
,
getExpandedTitleMarginEnd()
,
getExpandedTitleMarginBottom()
public int getExpandedTitleMarginStart()
setExpandedTitleMarginStart(int)
public void setExpandedTitleMarginStart(int margin)
margin
- the starting title margin in pixelsgetExpandedTitleMarginStart()
public int getExpandedTitleMarginTop()
setExpandedTitleMarginTop(int)
public void setExpandedTitleMarginTop(int margin)
margin
- the top title margin in pixelsgetExpandedTitleMarginTop()
public int getExpandedTitleMarginEnd()
setExpandedTitleMarginEnd(int)
public void setExpandedTitleMarginEnd(int margin)
margin
- the ending title margin in pixelsgetExpandedTitleMarginEnd()
public int getExpandedTitleMarginBottom()
setExpandedTitleMarginBottom(int)
public void setExpandedTitleMarginBottom(int margin)
margin
- the bottom title margin in pixelsgetExpandedTitleMarginBottom()
public void setScrimVisibleHeightTrigger(int height)
If the visible height of this view is less than the given value, the scrims will be made visible, otherwise they are hidden.
height
- value in pixels used to define when to trigger a scrim visibility changepublic int getScrimVisibleHeightTrigger()
setScrimVisibleHeightTrigger(int)
public void setScrimAnimationDuration(long duration)
duration
- the duration to use in millisecondspublic long getScrimAnimationDuration()
protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
checkLayoutParams
in class FrameLayout
protected CollapsingToolbarLayout.LayoutParams generateDefaultLayoutParams()
FrameLayout
ViewGroup.LayoutParams.MATCH_PARENT
,
and a height of ViewGroup.LayoutParams.MATCH_PARENT
.generateDefaultLayoutParams
in class FrameLayout
public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
ViewGroup
generateLayoutParams
in class FrameLayout
attrs
- the attributes to build the layout parameters fromViewGroup.LayoutParams
or one
of its descendantsprotected FrameLayout.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 FrameLayout
p
- The layout parameters to convert into a suitable set of layout parameters
for this ViewGroup.ViewGroup.LayoutParams
or one
of its descendants