public class NestedScrollView extends FrameLayout implements NestedScrollingParent, NestedScrollingChild, ScrollingView
ScrollView
, but it supports acting
as both a nested scrolling parent and child on both new and old versions of Android.
Nested scrolling is enabled by default.Modifier and Type | Class and Description |
---|---|
static interface |
NestedScrollView.OnScrollChangeListener
Interface definition for a callback to be invoked when the scroll
X or Y positions of a view change.
|
FrameLayout.LayoutParams
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
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.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 |
---|
NestedScrollView(Context context) |
NestedScrollView(Context context,
AttributeSet attrs) |
NestedScrollView(Context context,
AttributeSet attrs,
int defStyleAttr) |
Modifier and Type | Method and Description |
---|---|
void |
addView(View child)
Adds a child view.
|
void |
addView(View child,
int index)
Adds a child view.
|
void |
addView(View child,
int index,
ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters.
|
void |
addView(View child,
ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters.
|
boolean |
arrowScroll(int direction)
Handle scrolling in response to an up or down arrow click.
|
int |
computeHorizontalScrollExtent()
Compute the horizontal extent of the horizontal scrollbar's thumb
within the horizontal range.
|
int |
computeHorizontalScrollOffset()
Compute the horizontal offset of the horizontal scrollbar's thumb
within the horizontal range.
|
int |
computeHorizontalScrollRange()
Compute the horizontal range that the horizontal scrollbar
represents.
|
void |
computeScroll()
Called by a parent to request that a child update its values for mScrollX
and mScrollY if necessary.
|
protected int |
computeScrollDeltaToGetChildRectOnScreen(Rect rect)
Compute the amount to scroll in the Y direction in order to get
a rectangle completely on the screen (or, if taller than the screen,
at least the first screen size chunk of it).
|
int |
computeVerticalScrollExtent()
Compute the vertical extent of the vertical scrollbar's thumb
within the vertical range.
|
int |
computeVerticalScrollOffset()
Compute the vertical offset of the vertical scrollbar's thumb
within the horizontal range.
|
int |
computeVerticalScrollRange()
The scroll range of a scroll view is the overall height of all of its
children.
|
boolean |
dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path.
|
boolean |
dispatchNestedFling(float velocityX,
float velocityY,
boolean consumed)
Dispatch a fling to a nested scrolling parent.
|
boolean |
dispatchNestedPreFling(float velocityX,
float velocityY)
Dispatch a fling to a nested scrolling parent before it is processed by this view.
|
boolean |
dispatchNestedPreScroll(int dx,
int dy,
int[] consumed,
int[] offsetInWindow)
Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
|
boolean |
dispatchNestedScroll(int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed,
int[] offsetInWindow)
Dispatch one step of a nested scroll in progress.
|
void |
draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
|
boolean |
executeKeyEvent(KeyEvent event)
You can call this function yourself to have the scroll view perform
scrolling from a key event, just as if the event had been dispatched to
it by the view hierarchy.
|
void |
fling(int velocityY)
Fling the scroll view
|
boolean |
fullScroll(int direction)
Handles scrolling in response to a "home/end" shortcut press.
|
protected float |
getBottomFadingEdgeStrength()
Returns the strength, or intensity, of the bottom faded edge.
|
int |
getMaxScrollAmount() |
int |
getNestedScrollAxes()
Return the current axes of nested scrolling for this ViewGroup.
|
protected float |
getTopFadingEdgeStrength()
Returns the strength, or intensity, of the top faded edge.
|
boolean |
hasNestedScrollingParent()
Returns true if this view has a nested scrolling parent.
|
boolean |
isFillViewport()
Indicates whether this ScrollView's content is stretched to fill the viewport.
|
boolean |
isNestedScrollingEnabled()
Returns true if nested scrolling is enabled for this view.
|
boolean |
isSmoothScrollingEnabled() |
protected void |
measureChild(View child,
int parentWidthMeasureSpec,
int parentHeightMeasureSpec)
Ask one of the children of this view to measure itself, taking into
account both the MeasureSpec requirements for this view and its padding.
|
protected void |
measureChildWithMargins(View child,
int parentWidthMeasureSpec,
int widthUsed,
int parentHeightMeasureSpec,
int heightUsed)
Ask one of the children of this view to measure itself, taking into
account both the MeasureSpec requirements for this view and its padding
and margins.
|
void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
boolean |
onGenericMotionEvent(MotionEvent event)
Implement this method to handle generic motion events.
|
boolean |
onInterceptTouchEvent(MotionEvent ev)
Implement this method to intercept all touch screen motion events.
|
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.
|
boolean |
onNestedFling(View target,
float velocityX,
float velocityY,
boolean consumed)
Request a fling from a nested scroll.
|
boolean |
onNestedPreFling(View target,
float velocityX,
float velocityY)
React to a nested fling before the target view consumes it.
|
void |
onNestedPreScroll(View target,
int dx,
int dy,
int[] consumed)
React to a nested scroll in progress before the target view consumes a portion of the scroll.
|
void |
onNestedScroll(View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed)
React to a nested scroll in progress.
|
void |
onNestedScrollAccepted(View child,
View target,
int nestedScrollAxes)
React to the successful claiming of a nested scroll operation.
|
protected void |
onOverScrolled(int scrollX,
int scrollY,
boolean clampedX,
boolean clampedY)
Called by
View.overScrollBy(int, int, int, int, int, int, int, int, boolean) to
respond to the results of an over-scroll operation. |
protected boolean |
onRequestFocusInDescendants(int direction,
Rect previouslyFocusedRect)
When looking for focus in children of a scroll view, need to be a little
more careful not to give focus to something that is scrolled off screen.
|
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() . |
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 |
onScrollChanged(int l,
int t,
int oldl,
int oldt)
This is called in response to an internal scroll in this view (i.e., the
view scrolled its own contents).
|
protected void |
onSizeChanged(int w,
int h,
int oldw,
int oldh)
This is called during layout when the size of this view has changed.
|
boolean |
onStartNestedScroll(View child,
View target,
int nestedScrollAxes)
React to a descendant view initiating a nestable scroll operation, claiming the
nested scroll operation if appropriate.
|
void |
onStopNestedScroll(View target)
React to a nested scroll operation ending.
|
boolean |
onTouchEvent(MotionEvent ev)
Implement this method to handle touch screen motion events.
|
boolean |
pageScroll(int direction)
Handles scrolling in response to a "page up/down" shortcut press.
|
void |
requestChildFocus(View child,
View focused)
Called when a child of this parent wants focus
|
boolean |
requestChildRectangleOnScreen(View child,
Rect rectangle,
boolean immediate)
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
|
void |
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to
intercept touch events with
ViewGroup.onInterceptTouchEvent(MotionEvent) . |
void |
requestLayout()
Call this when something has changed which has invalidated the
layout of this view.
|
void |
scrollTo(int x,
int y)
Set the scrolled position of your view.
|
void |
setFillViewport(boolean fillViewport)
Set whether this ScrollView should stretch its content height to fill the viewport or not.
|
void |
setNestedScrollingEnabled(boolean enabled)
Enable or disable nested scrolling for this view.
|
void |
setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener l)
Register a callback to be invoked when the scroll X or Y positions of
this view change.
|
void |
setSmoothScrollingEnabled(boolean smoothScrollingEnabled)
Set whether arrow scrolling will animate its transition.
|
boolean |
shouldDelayChildPressedState()
Return true if the pressed state should be delayed for children or descendants of this
ViewGroup.
|
void |
smoothScrollBy(int dx,
int dy)
Like
View.scrollBy(int, int) , but scroll smoothly instead of immediately. |
void |
smoothScrollTo(int x,
int y)
Like
scrollTo(int, int) , but scroll smoothly instead of immediately. |
boolean |
startNestedScroll(int axes)
Begin a nestable scroll operation along the given axes.
|
void |
stopNestedScroll()
Stop a nested scroll in progress.
|
checkLayoutParams, encodeProperties, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getAccessibilityClassName, getConsiderGoneChildrenWhenMeasuring, getMeasureAllChildren, setForegroundGravity, setMeasureAllChildren
addChildrenForAccessibility, addFocusables, addStatesFromChildren, addTouchables, addTransientView, 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, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEventInternal, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, 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, 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, measureChildren, notifySubtreeAccessibilityStateChanged, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onChildVisibilityChanged, onCreateDrawableState, onDebugDraw, onDebugDrawMargins, onDetachedFromWindow, onInitializeAccessibilityNodeInfoInternal, onInterceptHoverEvent, onNestedPrePerformAccessibilityAction, onRequestSendAccessibilityEvent, onRequestSendAccessibilityEventInternal, onResolvePointerIcon, onSetLayoutParams, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, 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, computeOpaqueFlags, computeSystemWindowInsets, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, damageInParent, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchGenericMotionEvent, dispatchNestedPrePerformAccessibilityAction, 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, 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, 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, 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, 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, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityEventInternal, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPopulateAccessibilityEvent, onPopulateAccessibilityEventInternal, onProvideStructure, onProvideVirtualStructure, onRenderNodeDetached, onResolveDrawables, onRtlPropertiesChanged, onScreenStateChanged, onSetAlpha, 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, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetRtlProperties, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, 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, 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, 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
public NestedScrollView(Context context)
public NestedScrollView(Context context, AttributeSet attrs)
public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr)
public void setNestedScrollingEnabled(boolean enabled)
View
If this property is set to true the view will be permitted to initiate nested
scrolling operations with a compatible parent view in the current hierarchy. If this
view does not implement nested scrolling this will have no effect. Disabling nested scrolling
while a nested scroll is in progress has the effect of stopping
the nested scroll.
setNestedScrollingEnabled
in interface NestedScrollingChild
setNestedScrollingEnabled
in class View
enabled
- true to enable nested scrolling, false to disableView.isNestedScrollingEnabled()
public boolean isNestedScrollingEnabled()
View
If nested scrolling is enabled and this View class implementation supports it, this view will act as a nested scrolling child view when applicable, forwarding data about the scroll operation in progress to a compatible and cooperating nested scrolling parent.
isNestedScrollingEnabled
in interface NestedScrollingChild
isNestedScrollingEnabled
in class View
View.setNestedScrollingEnabled(boolean)
public boolean startNestedScroll(int axes)
View
A view starting a nested scroll promises to abide by the following contract:
The view will call startNestedScroll upon initiating a scroll operation. In the case
of a touch scroll this corresponds to the initial MotionEvent.ACTION_DOWN
.
In the case of touch scrolling the nested scroll will be terminated automatically in
the same manner as ViewParent.requestDisallowInterceptTouchEvent(boolean)
.
In the event of programmatic scrolling the caller must explicitly call
View.stopNestedScroll()
to indicate the end of the nested scroll.
If startNestedScroll
returns true, a cooperative parent was found.
If it returns false the caller may ignore the rest of this contract until the next scroll.
Calling startNestedScroll while a nested scroll is already in progress will return true.
At each incremental step of the scroll the caller should invoke
dispatchNestedPreScroll
once it has calculated the requested scrolling delta. If it returns true the nested scrolling
parent at least partially consumed the scroll and the caller should adjust the amount it
scrolls by.
After applying the remainder of the scroll delta the caller should invoke
dispatchNestedScroll
, passing
both the delta consumed and the delta unconsumed. A nested scrolling parent may treat
these values differently. See ViewParent.onNestedScroll(View, int, int, int, int)
.
startNestedScroll
in interface NestedScrollingChild
startNestedScroll
in class View
axes
- Flags consisting of a combination of View.SCROLL_AXIS_HORIZONTAL
and/or
View.SCROLL_AXIS_VERTICAL
.View.stopNestedScroll()
,
View.dispatchNestedPreScroll(int, int, int[], int[])
,
View.dispatchNestedScroll(int, int, int, int, int[])
public void stopNestedScroll()
View
Calling this method when a nested scroll is not currently in progress is harmless.
stopNestedScroll
in interface NestedScrollingChild
stopNestedScroll
in class View
View.startNestedScroll(int)
public boolean hasNestedScrollingParent()
View
The presence of a nested scrolling parent indicates that this view has initiated a nested scroll and it was accepted by an ancestor view further up the view hierarchy.
hasNestedScrollingParent
in interface NestedScrollingChild
hasNestedScrollingParent
in class View
public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow)
View
Implementations of views that support nested scrolling should call this to report
info about a scroll in progress to the current nested scrolling parent. If a nested scroll
is not currently in progress or nested scrolling is not
enabled
for this view this method does nothing.
Compatible View implementations should also call
dispatchNestedPreScroll
before
consuming a component of the scroll event themselves.
dispatchNestedScroll
in interface NestedScrollingChild
dispatchNestedScroll
in class View
dxConsumed
- Horizontal distance in pixels consumed by this view during this scroll stepdyConsumed
- Vertical distance in pixels consumed by this view during this scroll stepdxUnconsumed
- Horizontal scroll distance in pixels not consumed by this viewdyUnconsumed
- Horizontal scroll distance in pixels not consumed by this viewoffsetInWindow
- Optional. If not null, on return this will contain the offset
in local view coordinates of this view from before this operation
to after it completes. View implementations may use this to adjust
expected input coordinate tracking.View.dispatchNestedPreScroll(int, int, int[], int[])
public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow)
View
Nested pre-scroll events are to nested scroll events what touch intercept is to touch.
dispatchNestedPreScroll
offers an opportunity for the parent view in a nested
scrolling operation to consume some or all of the scroll operation before the child view
consumes it.
dispatchNestedPreScroll
in interface NestedScrollingChild
dispatchNestedPreScroll
in class View
dx
- Horizontal scroll distance in pixelsdy
- Vertical scroll distance in pixelsconsumed
- Output. If not null, consumed[0] will contain the consumed component of dx
and consumed[1] the consumed dy.offsetInWindow
- Optional. If not null, on return this will contain the offset
in local view coordinates of this view from before this operation
to after it completes. View implementations may use this to adjust
expected input coordinate tracking.View.dispatchNestedScroll(int, int, int, int, int[])
public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
View
This method should be used to indicate that a nested scrolling child has detected
suitable conditions for a fling. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds
the minimum fling velocity
along a scrollable axis.
If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.
dispatchNestedFling
in interface NestedScrollingChild
dispatchNestedFling
in class View
velocityX
- Horizontal fling velocity in pixels per secondvelocityY
- Vertical fling velocity in pixels per secondconsumed
- true if the child consumed the fling, false otherwisepublic boolean dispatchNestedPreFling(float velocityX, float velocityY)
View
Nested pre-fling events are to nested fling events what touch intercept is to touch
and what nested pre-scroll is to nested scroll. dispatchNestedPreFling
offsets an opportunity for the parent view in a nested fling to fully consume the fling
before the child view consumes it. If this method returns true
, a nested
parent view consumed the fling and this view should not scroll as a result.
For a better user experience, only one view in a nested scrolling chain should consume the fling at a time. If a parent view consumed the fling this method will return false. Custom view implementations should account for this in two ways:
dispatchNestedPreFling
; consume the fling and settle to a valid
position regardless.Views should also not offer fling velocities to nested parent views along an axis
where scrolling is not currently supported; a ScrollView
should not offer a horizontal fling velocity to its parents since scrolling along that
axis is not permitted and carrying velocity along that motion does not make sense.
dispatchNestedPreFling
in interface NestedScrollingChild
dispatchNestedPreFling
in class View
velocityX
- Horizontal fling velocity in pixels per secondvelocityY
- Vertical fling velocity in pixels per secondpublic boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)
ViewParent
This method will be called in response to a descendant view invoking
View.startNestedScroll(int)
. Each parent up the view hierarchy will be
given an opportunity to respond and claim the nested scrolling operation by returning
true
.
This method may be overridden by ViewParent implementations to indicate when the view
is willing to support a nested scrolling operation that is about to begin. If it returns
true, this ViewParent will become the target view's nested scrolling parent for the duration
of the scroll operation in progress. When the nested scroll is finished this ViewParent
will receive a call to ViewParent.onStopNestedScroll(View)
.
onStartNestedScroll
in interface NestedScrollingParent
onStartNestedScroll
in interface ViewParent
onStartNestedScroll
in class ViewGroup
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollnestedScrollAxes
- Flags consisting of View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
or bothpublic void onNestedScrollAccepted(View child, View target, int nestedScrollAxes)
ViewParent
This method will be called after
onStartNestedScroll
returns true. It offers
an opportunity for the view and its superclasses to perform initial configuration
for the nested scroll. Implementations of this method should always call their superclass's
implementation of this method if one is present.
onNestedScrollAccepted
in interface NestedScrollingParent
onNestedScrollAccepted
in interface ViewParent
onNestedScrollAccepted
in class ViewGroup
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollnestedScrollAxes
- Flags consisting of View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
or bothViewParent.onStartNestedScroll(View, View, int)
,
ViewParent.onStopNestedScroll(View)
public void onStopNestedScroll(View target)
ViewParent
Perform cleanup after a nested scrolling operation.
This method will be called when a nested scroll stops, for example when a nested touch
scroll ends with a MotionEvent.ACTION_UP
or MotionEvent.ACTION_CANCEL
event.
Implementations of this method should always call their superclass's implementation of this
method if one is present.
onStopNestedScroll
in interface NestedScrollingParent
onStopNestedScroll
in interface ViewParent
onStopNestedScroll
in class ViewGroup
target
- View that initiated the nested scrollpublic void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
ViewParent
This method will be called when the ViewParent's current nested scrolling child view
dispatches a nested scroll event. To receive calls to this method the ViewParent must have
previously returned true
for a call to
ViewParent.onStartNestedScroll(View, View, int)
.
Both the consumed and unconsumed portions of the scroll distance are reported to the ViewParent. An implementation may choose to use the consumed portion to match or chase scroll position of multiple child elements, for example. The unconsumed portion may be used to allow continuous dragging of multiple scrolling or draggable elements, such as scrolling a list within a vertical drawer where the drawer begins dragging once the edge of inner scrolling content is reached.
onNestedScroll
in interface NestedScrollingParent
onNestedScroll
in interface ViewParent
onNestedScroll
in class ViewGroup
target
- The descendent view controlling the nested scrolldxConsumed
- Horizontal scroll distance in pixels already consumed by targetdyConsumed
- Vertical scroll distance in pixels already consumed by targetdxUnconsumed
- Horizontal scroll distance in pixels not consumed by targetdyUnconsumed
- Vertical scroll distance in pixels not consumed by targetpublic void onNestedPreScroll(View target, int dx, int dy, int[] consumed)
ViewParent
When working with nested scrolling often the parent view may want an opportunity to consume the scroll before the nested scrolling child does. An example of this is a drawer that contains a scrollable list. The user will want to be able to scroll the list fully into view before the list itself begins scrolling.
onNestedPreScroll
is called when a nested scrolling child invokes
View.dispatchNestedPreScroll(int, int, int[], int[])
. The implementation should
report how any pixels of the scroll reported by dx, dy were consumed in the
consumed
array. Index 0 corresponds to dx and index 1 corresponds to dy.
This parameter will never be null. Initial values for consumed[0] and consumed[1]
will always be 0.
onNestedPreScroll
in interface NestedScrollingParent
onNestedPreScroll
in interface ViewParent
onNestedPreScroll
in class ViewGroup
target
- View that initiated the nested scrolldx
- Horizontal scroll distance in pixelsdy
- Vertical scroll distance in pixelsconsumed
- Output. The horizontal and vertical scroll distance consumed by this parentpublic boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)
ViewParent
This method signifies that a nested scrolling child has detected suitable conditions
for a fling. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds
the minimum fling velocity
along a scrollable axis.
If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.
onNestedFling
in interface NestedScrollingParent
onNestedFling
in interface ViewParent
onNestedFling
in class ViewGroup
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per secondconsumed
- true if the child consumed the fling, false otherwisepublic boolean onNestedPreFling(View target, float velocityX, float velocityY)
ViewParent
This method siginfies that a nested scrolling child has detected a fling with the given
velocity along each axis. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds
the minimum fling velocity
along a scrollable axis.
If a nested scrolling parent is consuming motion as part of a
pre-scroll
, it may be appropriate for
it to also consume the pre-fling to complete that same motion. By returning
true
from this method, the parent indicates that the child should not
fling its own internal content as well.
onNestedPreFling
in interface NestedScrollingParent
onNestedPreFling
in interface ViewParent
onNestedPreFling
in class ViewGroup
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per secondpublic int getNestedScrollAxes()
ViewGroup
A ViewGroup returning something other than View.SCROLL_AXIS_NONE
is currently
acting as a nested scrolling parent for one or more descendant views in the hierarchy.
getNestedScrollAxes
in interface NestedScrollingParent
getNestedScrollAxes
in class ViewGroup
View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
,
View.SCROLL_AXIS_NONE
public boolean shouldDelayChildPressedState()
ViewGroup
shouldDelayChildPressedState
in class FrameLayout
protected float getTopFadingEdgeStrength()
View
getTopFadingEdgeStrength
in class View
protected float getBottomFadingEdgeStrength()
View
getBottomFadingEdgeStrength
in class View
public int getMaxScrollAmount()
public void addView(View child)
ViewGroup
Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
ViewGroup.dispatchDraw(android.graphics.Canvas)
or any related method.
addView
in class ViewGroup
child
- the child view to addViewGroup.generateDefaultLayoutParams()
public void addView(View child, int index)
ViewGroup
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
ViewGroup.dispatchDraw(android.graphics.Canvas)
or any related method.
addView
in class ViewGroup
child
- the child view to addindex
- the position at which to add the childViewGroup.generateDefaultLayoutParams()
public void addView(View child, ViewGroup.LayoutParams params)
ViewGroup
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
ViewGroup.dispatchDraw(android.graphics.Canvas)
or any related method.
addView
in interface ViewManager
addView
in class ViewGroup
child
- the child view to addparams
- the layout parameters to set on the childpublic void addView(View child, int index, ViewGroup.LayoutParams params)
ViewGroup
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
ViewGroup.dispatchDraw(android.graphics.Canvas)
or any related method.
public void setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener l)
This version of the method works on all versions of Android, back to API v4.
l
- The listener to notify when the scroll X or Y position changes.View.getScrollX()
,
View.getScrollY()
public boolean isFillViewport()
public void setFillViewport(boolean fillViewport)
fillViewport
- True to stretch the content's height to the viewport's
boundaries, false otherwise.public boolean isSmoothScrollingEnabled()
public void setSmoothScrollingEnabled(boolean smoothScrollingEnabled)
smoothScrollingEnabled
- whether arrow scrolling will animate its transitionprotected void onScrollChanged(int l, int t, int oldl, int oldt)
View
View.scrollBy(int, int)
or View.scrollTo(int, int)
having been
called.onScrollChanged
in class View
l
- Current horizontal scroll origin.t
- Current vertical scroll origin.oldl
- Previous horizontal scroll origin.oldt
- Previous vertical scroll origin.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)
public boolean dispatchKeyEvent(KeyEvent event)
View
dispatchKeyEvent
in class ViewGroup
event
- The key event to be dispatched.public boolean executeKeyEvent(KeyEvent event)
event
- The key event to execute.public void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
ViewParent
ViewGroup.onInterceptTouchEvent(MotionEvent)
.
This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.
requestDisallowInterceptTouchEvent
in interface ViewParent
requestDisallowInterceptTouchEvent
in class ViewGroup
disallowIntercept
- True if the child does not want the parent to
intercept touch events.public boolean onInterceptTouchEvent(MotionEvent ev)
ViewGroup
Using this function takes some care, as it has a fairly complicated
interaction with View.onTouchEvent(MotionEvent)
, and using it requires implementing
that method as well as this one in the correct way. Events will be
received in the following order:
MotionEvent.ACTION_CANCEL
, and all further
events will be delivered to your onTouchEvent() method and no longer
appear here.
onInterceptTouchEvent
in class ViewGroup
ev
- The motion event being dispatched down the hierarchy.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.public boolean onGenericMotionEvent(MotionEvent event)
View
Generic motion events describe joystick movements, mouse hovers, track pad
touches, scroll wheel movements and other input events. The
source
of the motion event specifies
the class of input that was received. Implementations of this method
must examine the bits in the source before processing the event.
The following code example shows how this is done.
Generic motion events with source class InputDevice.SOURCE_CLASS_POINTER
are delivered to the view under the pointer. All other generic motion events are
delivered to the focused view.
public boolean onGenericMotionEvent(MotionEvent event) { if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { if (event.getAction() == MotionEvent.ACTION_MOVE) { // process the joystick movement... return true; } } if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { switch (event.getAction()) { case MotionEvent.ACTION_HOVER_MOVE: // process the mouse hover movement... return true; case MotionEvent.ACTION_SCROLL: // process the scroll wheel movement... return true; } } return super.onGenericMotionEvent(event); }
onGenericMotionEvent
in class View
event
- The generic motion event being processed.protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY)
View
View.overScrollBy(int, int, int, int, int, int, int, int, boolean)
to
respond to the results of an over-scroll operation.onOverScrolled
in class View
scrollX
- New X scroll value in pixelsscrollY
- New Y scroll value in pixelsclampedX
- True if scrollX was clamped to an over-scroll boundaryclampedY
- True if scrollY was clamped to an over-scroll boundarypublic boolean pageScroll(int direction)
Handles scrolling in response to a "page up/down" shortcut press. This method will scroll the view by one page up or down and give the focus to the topmost/bottommost component in the new visible area. If no component is a good candidate for focus, this scrollview reclaims the focus.
direction
- the scroll direction: View.FOCUS_UP
to go one page up or
View.FOCUS_DOWN
to go one page downpublic boolean fullScroll(int direction)
Handles scrolling in response to a "home/end" shortcut press. This method will scroll the view to the top or bottom and give the focus to the topmost/bottommost component in the new visible area. If no component is a good candidate for focus, this scrollview reclaims the focus.
direction
- the scroll direction: View.FOCUS_UP
to go the top of the view or
View.FOCUS_DOWN
to go the bottompublic boolean arrowScroll(int direction)
direction
- The direction corresponding to the arrow key that was
pressedpublic final void smoothScrollBy(int dx, int dy)
View.scrollBy(int, int)
, but scroll smoothly instead of immediately.dx
- the number of pixels to scroll by on the X axisdy
- the number of pixels to scroll by on the Y axispublic final void smoothScrollTo(int x, int y)
scrollTo(int, int)
, but scroll smoothly instead of immediately.x
- the position where to scroll on the X axisy
- the position where to scroll on the Y axispublic int computeVerticalScrollRange()
The scroll range of a scroll view is the overall height of all of its children.
computeVerticalScrollRange
in interface ScrollingView
computeVerticalScrollRange
in class View
The default range is the drawing height of this view.
View.computeVerticalScrollExtent()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
public int computeVerticalScrollOffset()
View
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollRange()
and
View.computeVerticalScrollExtent()
.
The default offset is the scroll offset of this view.
computeVerticalScrollOffset
in interface ScrollingView
computeVerticalScrollOffset
in class View
View.computeVerticalScrollRange()
,
View.computeVerticalScrollExtent()
,
ScrollBarDrawable
public int computeVerticalScrollExtent()
View
Compute the vertical extent of the vertical scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollRange()
and
View.computeVerticalScrollOffset()
.
The default extent is the drawing height of this view.
computeVerticalScrollExtent
in interface ScrollingView
computeVerticalScrollExtent
in class View
View.computeVerticalScrollRange()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
public int computeHorizontalScrollRange()
View
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollExtent()
and
View.computeHorizontalScrollOffset()
.
The default range is the drawing width of this view.
computeHorizontalScrollRange
in interface ScrollingView
computeHorizontalScrollRange
in class View
View.computeHorizontalScrollExtent()
,
View.computeHorizontalScrollOffset()
,
ScrollBarDrawable
public int computeHorizontalScrollOffset()
View
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollRange()
and
View.computeHorizontalScrollExtent()
.
The default offset is the scroll offset of this view.
computeHorizontalScrollOffset
in interface ScrollingView
computeHorizontalScrollOffset
in class View
View.computeHorizontalScrollRange()
,
View.computeHorizontalScrollExtent()
,
ScrollBarDrawable
public int computeHorizontalScrollExtent()
View
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollRange()
and
View.computeHorizontalScrollOffset()
.
The default extent is the drawing width of this view.
computeHorizontalScrollExtent
in interface ScrollingView
computeHorizontalScrollExtent
in class View
View.computeHorizontalScrollRange()
,
View.computeHorizontalScrollOffset()
,
ScrollBarDrawable
protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec)
ViewGroup
measureChild
in class ViewGroup
child
- The child to measureparentWidthMeasureSpec
- The width requirements for this viewparentHeightMeasureSpec
- The height requirements for this viewprotected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
ViewGroup
measureChildWithMargins
in class ViewGroup
child
- The child to measureparentWidthMeasureSpec
- The width requirements for this viewwidthUsed
- Extra space that has been used up by the parent
horizontally (possibly by other children of the parent)parentHeightMeasureSpec
- The height requirements for this viewheightUsed
- Extra space that has been used up by the parent
vertically (possibly by other children of the parent)public void computeScroll()
View
Scroller
object.computeScroll
in class View
protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect)
rect
- The rect.public void requestChildFocus(View child, View focused)
ViewParent
requestChildFocus
in interface ViewParent
requestChildFocus
in class ViewGroup
child
- The child of this ViewParent that wants focus. This view
will contain the focused view. It is not necessarily the view that
actually has focus.focused
- The view that is a descendant of child that actually has
focusprotected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
ViewGroup
implementation, otherwise this behavior might have been made the default.onRequestFocusInDescendants
in class ViewGroup
direction
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHTpreviouslyFocusedRect
- The rectangle (in this View's coordinate system)
to give a finer grained hint about where focus is coming from. May be null
if there is no hint.public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)
ViewParent
ViewGroup
s overriding this can trust
that:
ViewGroup
s overriding this should uphold the contract:
requestChildRectangleOnScreen
in interface ViewParent
requestChildRectangleOnScreen
in class ViewGroup
child
- The direct child making the request.rectangle
- The rectangle in the child's coordinates the child
wishes to be on the screen.immediate
- True to forbid animated or delayed scrolling,
false otherwisepublic void requestLayout()
View
View.isInLayout()
. If layout is happening, the request may be honored at the
end of the current layout pass (and then layout will run again) or after the current
frame is drawn and the next layout occurs.
Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.
requestLayout
in interface ViewParent
requestLayout
in class View
protected void onLayout(boolean changed, int l, int t, int r, int b)
View
onLayout
in class FrameLayout
changed
- This is a new size or position for this viewl
- Left position, relative to parentt
- Top position, relative to parentr
- Right position, relative to parentb
- Bottom position, relative to parentpublic 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 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.public void fling(int velocityY)
velocityY
- The initial velocity in the Y direction. Positive
numbers mean that the finger/cursor is moving down the screen,
which means we want to scroll towards the top.public void scrollTo(int x, int y)
View.onScrollChanged(int, int, int, int)
and the view will be
invalidated.
This version also clamps the scrolling to the bounds of our child.
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 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 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)