Class NestedScrollView
- All Implemented Interfaces:
Drawable.Callback
,ViewManager
,ViewParent
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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface definition for a callback to be invoked when the scroll X or Y positions of a view change.Nested classes/interfaces inherited from class icyllis.modernui.widget.FrameLayout
FrameLayout.LayoutParams
Nested classes/interfaces inherited from class icyllis.modernui.view.ViewGroup
ViewGroup.MarginLayoutParams
Nested classes/interfaces inherited from class icyllis.modernui.view.View
View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
-
Field Summary
Fields inherited from class icyllis.modernui.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_DISALLOW_INTERCEPT, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS
Fields inherited from class icyllis.modernui.view.View
ALPHA, BOTTOM, 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, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, 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, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, LEFT, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mScrollX, mScrollY, NO_ID, NOT_FOCUSABLE, 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, RIGHT, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, 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, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, 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, TOP, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a child view.void
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
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range.int
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range.int
Compute the horizontal range that the horizontal scrollbar represents.void
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary.protected int
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
Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.int
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range.int
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
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 viewboolean
fullScroll
(int direction) Handles scrolling in response to a "home/end" shortcut press.int
boolean
Indicates whether this ScrollView's content is stretched to fill the viewport.boolean
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
This is called when the view is attached to a window.void
onDrawForeground
(Canvas canvas) Draw any foreground content for this view.boolean
onGenericMotionEvent
(MotionEvent event) Implement this method to handle generic motion events.boolean
Implement this method to intercept all touch screen motion events.protected void
onLayout
(boolean changed, int l, int t, int r, int b) Called fromView.layout(int, int, int, int)
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, int type) 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, int type, int[] consumed) React to a nested scroll in progress.void
onNestedScrollAccepted
(View child, View target, int axes, int type) React to the successful claiming of a nested scroll operation.protected void
onOverScrolled
(int scrollX, int scrollY, boolean clampedX, boolean clampedY) Called byView.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
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) Called when width or height changedboolean
onStartNestedScroll
(View child, View target, int axes, int type) React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.void
onStopNestedScroll
(View target, int type) React to a nested scroll operation ending.boolean
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 focusboolean
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 withViewGroup.onInterceptTouchEvent(MotionEvent)
.void
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
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
Return true if the pressed state should be delayed for children or descendants of this ViewGroup.final void
smoothScrollBy
(int dx, int dy) LikeView.scrollBy(int, int)
, but scroll smoothly instead of immediately.final void
smoothScrollBy
(int dx, int dy, int scrollDurationMs) LikeView.scrollBy(int, int)
, but scroll smoothly instead of immediately.final void
smoothScrollTo
(int x, int y) LikescrollTo(int, int)
, but scroll smoothly instead of immediately.final void
smoothScrollTo
(int x, int y, int scrollDurationMs) LikescrollTo(int, int)
, but scroll smoothly instead of immediately.Methods inherited from class icyllis.modernui.widget.FrameLayout
checkLayoutParams, generateDefaultLayoutParams, generateLayoutParams, getMeasureAllChildren, setForegroundGravity, setMeasureAllChildren
Methods inherited from class icyllis.modernui.view.ViewGroup
addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addTransientView, addView, addViewInLayout, addViewInLayout, attachViewToParent, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyShortcutEvent, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchTouchEvent, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findViewByPredicateTraversal, findViewTraversal, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildDrawingOrder, getChildMeasureSpec, getChildVisibleRect, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutTransition, getNestedScrollAxes, getTouchscreenBlocksFocus, getTransientView, getTransientViewCount, getTransientViewIndex, hasBooleanFlag, hasFocus, hasTransientState, indexOfChild, internalSetPadding, isChildrenDrawingOrderEnabled, isLayoutSuppressed, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChildren, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onChildVisibilityChanged, onCreateDrawableState, onInterceptHoverEvent, onResolvePointerIcon, onSetLayoutParams, onViewAdded, onViewRemoved, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestFocus, requestTransitionStart, resetResolvedDrawables, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveTextAlignment, resolveTextDirection, restoreDefaultFocus, setAddStatesFromChildren, setBooleanFlag, setChildrenDrawingOrderEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutTransition, setTouchscreenBlocksFocus, setTransitionGroup, showContextMenuForChild, startActionModeForChild, startViewTransition, suppressLayout, transformPointToViewLocal, updateViewLayout
Methods inherited from class icyllis.modernui.view.View
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, awakenScrollBars, awakenScrollBars, callOnClick, cancelLongPress, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, combineMeasuredStates, createContextMenu, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dp, draw, drawableHotspotChanged, findViewById, findViewByPredicate, findViewByPredicateInsideOut, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBaseline, getBottom, getBoundsOnScreen, getBoundsOnScreen, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, handleScrollBarDragging, hasExplicitFocusable, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTranslationTransientState, hasWindowFocus, invalidate, invalidateDrawable, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCancelPendingInputEvents, onCreateContextMenu, onDetachedFromWindow, onDragEvent, onDraw, onDrawScrollBars, onFinishTemporaryDetach, onFocusChanged, onHoverChanged, onHoverEvent, onKeyDown, onKeyShortcut, onKeyUp, onResolveDrawables, onRtlPropertiesChanged, onStartTemporaryDetach, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resolveSize, resolveSizeAndState, scheduleDrawable, scrollBy, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setContextClickable, setDuplicateParentStateEnabled, setElevation, setEnabled, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setFocusedInCluster, setForeground, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotDraw
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface icyllis.modernui.view.ViewParent
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch
-
Constructor Details
-
NestedScrollView
-
-
Method Details
-
onNestedScroll
public void onNestedScroll(@Nonnull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, @Nonnull int[] consumed) Description copied from interface:ViewParent
React to a nested scroll in progress.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 toViewParent.onStartNestedScroll(View, View, int, 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.
This method is called when a nested scrolling child invokes
View.dispatchNestedScroll(int, int, int, int, int[], int, int[])
} or one of methods it overloads.An implementation must report how many pixels of the x and y scroll distances were consumed by this nested scrolling parent by adding the consumed distances to the
consumed
parameter.consumed
should also be passed up to it's nested scrolling parent so that the parent may also add any scroll distance it consumes. Index 0 corresponds to dx and index 1 corresponds to dy.- Specified by:
onNestedScroll
in interfaceViewParent
- Overrides:
onNestedScroll
in classViewGroup
- Parameters:
target
- The descendant 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 targettype
- the type of input which cause this scroll eventconsumed
- Output. Upon this method returning, will contain the scroll distances consumed by this nested scrolling parent and the scroll distances consumed by any other parent up the view hierarchy- See Also:
-
onStartNestedScroll
Description copied from interface:ViewParent
React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.This method will be called in response to a descendant view invoking
View.startNestedScroll(int, int)
. Each parent up the view hierarchy will be given an opportunity to respond and claim the nested scrolling operation by returningtrue
.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, int)
.- Specified by:
onStartNestedScroll
in interfaceViewParent
- Overrides:
onStartNestedScroll
in classViewGroup
- Parameters:
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollaxes
- Flags consisting ofView.SCROLL_AXIS_HORIZONTAL
,View.SCROLL_AXIS_VERTICAL
or bothtype
- the type of input which cause this scroll event- Returns:
- true if this ViewParent accepts the nested scroll operation
-
onNestedScrollAccepted
Description copied from interface:ViewParent
React to the successful claiming of a nested scroll operation.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 superclasses' implementation of this method if one is present.- Specified by:
onNestedScrollAccepted
in interfaceViewParent
- Overrides:
onNestedScrollAccepted
in classViewGroup
- Parameters:
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollaxes
- Flags consisting ofView.SCROLL_AXIS_HORIZONTAL
,View.SCROLL_AXIS_VERTICAL
or bothtype
- the type of input which cause this scroll event- See Also:
-
onStopNestedScroll
Description copied from interface:ViewParent
React to a nested scroll operation ending.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
orMotionEvent.ACTION_CANCEL
event. Implementations of this method should always call their superclasses' implementation of this method if one is present.- Specified by:
onStopNestedScroll
in interfaceViewParent
- Overrides:
onStopNestedScroll
in classViewGroup
- Parameters:
target
- View that initiated the nested scrolltype
- the type of input which cause this scroll event
-
onNestedPreScroll
public void onNestedPreScroll(@Nonnull View target, int dx, int dy, @Nonnull int[] consumed, int type) Description copied from interface:ViewParent
React to a nested scroll in progress before the target view consumes a portion of the scroll.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 invokesView.dispatchNestedPreScroll(int, int, int[], int[], int)
. The implementation should report how any pixels of the scroll reported by dx, dy were consumed in theconsumed
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.- Specified by:
onNestedPreScroll
in interfaceViewParent
- Overrides:
onNestedPreScroll
in classViewGroup
- Parameters:
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 parenttype
- the type of input which cause this scroll event
-
onNestedFling
public boolean onNestedFling(@Nonnull View target, float velocityX, float velocityY, boolean consumed) Description copied from interface:ViewParent
Request a fling from a nested scroll.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 theminimum 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.
- Specified by:
onNestedFling
in interfaceViewParent
- Overrides:
onNestedFling
in classViewGroup
- Parameters:
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 otherwise- Returns:
- true if this parent consumed or otherwise reacted to the fling
-
onNestedPreFling
Description copied from interface:ViewParent
React to a nested fling before the target view consumes it.This method signifies 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 theminimum 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 returningtrue
from this method, the parent indicates that the child should not fling its own internal content as well.- Specified by:
onNestedPreFling
in interfaceViewParent
- Overrides:
onNestedPreFling
in classViewGroup
- Parameters:
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per second- Returns:
- true if this parent consumed the fling ahead of the target view
-
shouldDelayChildPressedState
public boolean shouldDelayChildPressedState()Description copied from class:ViewGroup
Return true if the pressed state should be delayed for children or descendants of this ViewGroup. Generally, this should be done for containers that can scroll, such as a List. This prevents the pressed state from appearing when the user is actually trying to scroll the content.The default implementation returns true for compatibility reasons. Subclasses that do not scroll should generally override this method and return false.
- Overrides:
shouldDelayChildPressedState
in classViewGroup
-
getMaxScrollAmount
public int getMaxScrollAmount()- Returns:
- The maximum amount this scroll view will scroll in response to an arrow event.
-
addView
Description copied from class: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(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method. -
addView
Description copied from class: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(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method. -
addView
Description copied from class:ViewGroup
Adds a child view with the specified layout parameters.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method.- Specified by:
addView
in interfaceViewManager
- Overrides:
addView
in classViewGroup
- Parameters:
child
- the child view to addparams
- the layout parameters to set on the child
-
addView
Description copied from class:ViewGroup
Adds a child view with the specified layout parameters.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,ViewGroup.dispatchDraw(Canvas)
or any related method. -
setOnScrollChangeListener
Register a callback to be invoked when the scroll X or Y positions of this view change.This version of the method works on all versions of Android, back to API v4.
- Parameters:
l
- The listener to notify when the scroll X or Y position changes.- See Also:
-
isFillViewport
public boolean isFillViewport()Indicates whether this ScrollView's content is stretched to fill the viewport.- Returns:
- True if the content fills the viewport, false otherwise.
-
setFillViewport
public void setFillViewport(boolean fillViewport) Set whether this ScrollView should stretch its content height to fill the viewport or not.- Parameters:
fillViewport
- True to stretch the content's height to the viewport's boundaries, false otherwise.
-
isSmoothScrollingEnabled
public boolean isSmoothScrollingEnabled()- Returns:
- Whether arrow scrolling will animate its transition.
-
setSmoothScrollingEnabled
public void setSmoothScrollingEnabled(boolean smoothScrollingEnabled) Set whether arrow scrolling will animate its transition.- Parameters:
smoothScrollingEnabled
- whether arrow scrolling will animate its transition
-
onScrollChanged
protected void onScrollChanged(int l, int t, int oldl, int oldt) Description copied from class:View
This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents). This is typically as a result ofView.scrollBy(int, int)
orView.scrollTo(int, int)
having been called.- Overrides:
onScrollChanged
in classView
- Parameters:
l
- Current horizontal scroll origin.t
- Current vertical scroll origin.oldl
- Previous horizontal scroll origin.oldt
- Previous vertical scroll origin.
-
onMeasure
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) Description copied from class:View
Measure the view and its content to determine the measured width and the measured height. This method is invoked byView.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 anIllegalStateException
, thrown byView.measure(int, int)
. Calling super.onMeasure() 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 the base one to provide better measurements of their content.
- Overrides:
onMeasure
in classFrameLayout
- Parameters:
widthMeasureSpec
- width measure specification imposed by the parentMeasureSpec
heightMeasureSpec
- height measure specification imposed by the parentMeasureSpec
-
dispatchKeyEvent
Description copied from class:View
Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.- Overrides:
dispatchKeyEvent
in classViewGroup
- Parameters:
event
- The key event to be dispatched.- Returns:
- True if the event was handled, false otherwise.
-
executeKeyEvent
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.- Parameters:
event
- The key event to execute.- Returns:
- Return true if the event was handled, else false.
-
requestDisallowInterceptTouchEvent
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) Description copied from interface:ViewParent
Called when a child does not want this parent and its ancestors to intercept touch events withViewGroup.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.
- Specified by:
requestDisallowInterceptTouchEvent
in interfaceViewParent
- Overrides:
requestDisallowInterceptTouchEvent
in classViewGroup
- Parameters:
disallowIntercept
- True if the child does not want the parent to intercept touch events.
-
onInterceptTouchEvent
Description copied from class:ViewGroup
Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.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:- You will receive the down event here.
- The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
- For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
- If you return true from here, you will not receive any
following events: the target view will receive the same event but
with the action
MotionEvent.ACTION_CANCEL
, and all further events will be delivered to your onTouchEvent() method and no longer appear here.
- Overrides:
onInterceptTouchEvent
in classViewGroup
- Parameters:
ev
- The motion event being dispatched down the hierarchy.- Returns:
- Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.
-
onTouchEvent
Description copied from class:View
Implement this method to handle touch screen motion events.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.- Overrides:
onTouchEvent
in classView
- Parameters:
ev
- the touch event- Returns:
true
if the event was handled by the view,false
otherwise
-
onGenericMotionEvent
Description copied from class:View
Implement this method to handle generic motion events.Implementations of this method should check if this view ENABLED and CLICKABLE.
- Overrides:
onGenericMotionEvent
in classView
- Parameters:
event
- the generic motion event being processed.- Returns:
true
if the event was consumed by the view,false
otherwise
-
onOverScrolled
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) Description copied from class:View
Called byView.overScrollBy(int, int, int, int, int, int, int, int, boolean)
to respond to the results of an over-scroll operation.- Overrides:
onOverScrolled
in classView
- Parameters:
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 boundary
-
pageScroll
public 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.
- Parameters:
direction
- the scroll direction:View.FOCUS_UP
to go one page up orView.FOCUS_DOWN
to go one page down- Returns:
- true if the key event is consumed by this method, false otherwise
-
fullScroll
public 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.
- Parameters:
direction
- the scroll direction:View.FOCUS_UP
to go the top of the view orView.FOCUS_DOWN
to go the bottom- Returns:
- true if the key event is consumed by this method, false otherwise
-
arrowScroll
public boolean arrowScroll(int direction) Handle scrolling in response to an up or down arrow click.- Parameters:
direction
- The direction corresponding to the arrow key that was pressed- Returns:
- True if we consumed the event, false otherwise
-
smoothScrollBy
public final void smoothScrollBy(int dx, int dy) LikeView.scrollBy(int, int)
, but scroll smoothly instead of immediately.- Parameters:
dx
- the number of pixels to scroll by on the X axisdy
- the number of pixels to scroll by on the Y axis
-
smoothScrollBy
public final void smoothScrollBy(int dx, int dy, int scrollDurationMs) LikeView.scrollBy(int, int)
, but scroll smoothly instead of immediately.- Parameters:
dx
- the number of pixels to scroll by on the X axisdy
- the number of pixels to scroll by on the Y axisscrollDurationMs
- the duration of the smooth scroll operation in milliseconds
-
smoothScrollTo
public final void smoothScrollTo(int x, int y) LikescrollTo(int, int)
, but scroll smoothly instead of immediately.- Parameters:
x
- the position where to scroll on the X axisy
- the position where to scroll on the Y axis
-
smoothScrollTo
public final void smoothScrollTo(int x, int y, int scrollDurationMs) LikescrollTo(int, int)
, but scroll smoothly instead of immediately.- Parameters:
x
- the position where to scroll on the X axisy
- the position where to scroll on the Y axisscrollDurationMs
- the duration of the smooth scroll operation in milliseconds
-
computeVerticalScrollRange
public int computeVerticalScrollRange()The scroll range of a scroll view is the overall height of all of its children.
- Overrides:
computeVerticalScrollRange
in classView
- Returns:
- the total vertical range represented by the vertical scrollbar
The default range is the drawing height of this view.
- See Also:
-
computeVerticalScrollOffset
public int computeVerticalScrollOffset()Description copied from class: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()
andView.computeVerticalScrollExtent()
.The default offset is the scroll offset of this view.
- Overrides:
computeVerticalScrollOffset
in classView
- Returns:
- the vertical offset of the scrollbar's thumb
- See Also:
-
computeVerticalScrollExtent
public int computeVerticalScrollExtent()Description copied from class: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()
andView.computeVerticalScrollOffset()
.The default extent is the drawing height of this view.
- Overrides:
computeVerticalScrollExtent
in classView
- Returns:
- the vertical extent of the scrollbar's thumb
- See Also:
-
computeHorizontalScrollRange
public int computeHorizontalScrollRange()Description copied from class: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()
andView.computeHorizontalScrollOffset()
.The default range is the drawing width of this view.
- Overrides:
computeHorizontalScrollRange
in classView
- Returns:
- the total horizontal range represented by the horizontal scrollbar
- See Also:
-
computeHorizontalScrollOffset
public int computeHorizontalScrollOffset()Description copied from class: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()
andView.computeHorizontalScrollExtent()
.The default offset is the scroll offset of this view.
- Overrides:
computeHorizontalScrollOffset
in classView
- Returns:
- the horizontal offset of the scrollbar's thumb
- See Also:
-
computeHorizontalScrollExtent
public int computeHorizontalScrollExtent()Description copied from class: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()
andView.computeHorizontalScrollOffset()
.The default extent is the drawing width of this view.
- Overrides:
computeHorizontalScrollExtent
in classView
- Returns:
- the horizontal extent of the scrollbar's thumb
- See Also:
-
measureChild
protected void measureChild(@Nonnull View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) Description copied from class:ViewGroup
Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding. The heavy lifting is done in getChildMeasureSpec.- Overrides:
measureChild
in classViewGroup
- Parameters:
child
- The child to measureparentWidthMeasureSpec
- The width requirements for this viewparentHeightMeasureSpec
- The height requirements for this view
-
measureChildWithMargins
protected void measureChildWithMargins(@Nonnull View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) Description copied from class:ViewGroup
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. The child must have MarginLayoutParams The heavy lifting is done in getChildMeasureSpec.- Overrides:
measureChildWithMargins
in classViewGroup
- Parameters:
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)
-
computeScroll
public void computeScroll()Description copied from class:View
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a Scroller.- Overrides:
computeScroll
in classView
-
computeScrollDeltaToGetChildRectOnScreen
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).- Parameters:
rect
- The rect.- Returns:
- The scroll delta.
-
requestChildFocus
Description copied from interface:ViewParent
Called when a child of this parent wants focus- Specified by:
requestChildFocus
in interfaceViewParent
- Overrides:
requestChildFocus
in classViewGroup
- Parameters:
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 focus
-
onRequestFocusInDescendants
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.This is more expensive than the default
ViewGroup
implementation, otherwise this behavior might have been made the default.- Overrides:
onRequestFocusInDescendants
in classViewGroup
- Parameters:
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.- Returns:
- Whether focus was taken.
-
requestChildRectangleOnScreen
Description copied from interface:ViewParent
Called when a child of this group wants a particular rectangle to be positioned onto the screen.ViewGroup
s overriding this can trust that:- child will be a direct child of this group
- rectangle will be in the child's content coordinates
ViewGroup
s overriding this should uphold the contract:- nothing will change if the rectangle is already visible
- the view port will be scrolled only just enough to make the rectangle visible
- Specified by:
requestChildRectangleOnScreen
in interfaceViewParent
- Overrides:
requestChildRectangleOnScreen
in classViewGroup
- Parameters:
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 otherwise- Returns:
- Whether the group scrolled to handle the operation
-
requestLayout
public void requestLayout()Description copied from class:View
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (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.
- Specified by:
requestLayout
in interfaceViewParent
- Overrides:
requestLayout
in classView
-
onLayout
protected void onLayout(boolean changed, int l, int t, int r, int b) Description copied from class:View
Called fromView.layout(int, int, int, int)
when this view should assign a size and position to each of its children.Derived classes with children should override this method and call layout on each of their children.
- Overrides:
onLayout
in classFrameLayout
- Parameters:
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 parent
-
onAttachedToWindow
public void onAttachedToWindow()Description copied from class:View
This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called beforeView.onDraw(Canvas)
, however it may be called any time before the first onDraw -- including before or afterView.onMeasure(int, int)
.- Overrides:
onAttachedToWindow
in classView
- See Also:
-
onSizeChanged
protected void onSizeChanged(int w, int h, int oldw, int oldh) Description copied from class:View
Called when width or height changed- Overrides:
onSizeChanged
in classView
- Parameters:
w
- new widthh
- new heightoldw
- previous widtholdh
- previous height
-
fling
public void fling(int velocityY) Fling the scroll view- Parameters:
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.
-
scrollTo
public void scrollTo(int x, int y) Set the scrolled position of your view. This will cause a call toView.onScrollChanged(int, int, int, int)
and the view will be invalidated.This version also clamps the scrolling to the bounds of our child.
-
onDrawForeground
Description copied from class:View
Draw any foreground content for this view.Foreground content may consist of scroll bars, a
foreground
drawable or other view-specific decorations. The foreground is drawn on top of the primary view content.- Overrides:
onDrawForeground
in classView
- Parameters:
canvas
- the canvas to draw content
-