java.lang.Object | ||||
↳ | android.view.View | |||
↳ | android.view.ViewGroup | |||
↳ | android.widget.FrameLayout | |||
↳ | android.support.v4.widget.NestedScrollView |
NestedScrollView is just like 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.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
android:fillViewport | setFillViewport(boolean) | Defines whether the scrollview should stretch its content to fill the viewport. |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.FrameLayout
| |||||||||||
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a child view.
| |||||||||||
Adds a child view with the specified layout parameters.
| |||||||||||
Adds a child view. | |||||||||||
Adds a child view with the specified layout parameters.
| |||||||||||
Handle scrolling in response to an up or down arrow click.
| |||||||||||
Called by a parent to request that a child update its values for mScrollX
and mScrollY if necessary.
| |||||||||||
Dispatch a key event to the next view on the focus path.
| |||||||||||
Dispatch a fling to a nested scrolling parent.
| |||||||||||
Dispatch a fling to a nested scrolling parent before it is processed by this view.
| |||||||||||
Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
| |||||||||||
Dispatch one step of a nested scroll in progress.
| |||||||||||
Manually render this view (and all of its children) to the given Canvas.
| |||||||||||
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.
| |||||||||||
Fling the scroll view
| |||||||||||
Handles scrolling in response to a "home/end" shortcut press. | |||||||||||
Return the current axes of nested scrolling for this ViewGroup.
| |||||||||||
Returns true if this view has a nested scrolling parent.
| |||||||||||
Indicates whether this ScrollView's content is stretched to fill the viewport.
| |||||||||||
Returns true if nested scrolling is enabled for this view.
| |||||||||||
This is called when the view is attached to a window.
| |||||||||||
Implement this method to handle generic motion events.
| |||||||||||
Implement this method to intercept all touch screen motion events.
| |||||||||||
Request a fling from a nested scroll.
| |||||||||||
React to a nested fling before the target view consumes it.
| |||||||||||
React to a nested scroll in progress before the target view consumes a portion of the scroll.
| |||||||||||
React to a nested scroll in progress.
| |||||||||||
React to the successful claiming of a nested scroll operation.
| |||||||||||
React to a descendant view initiating a nestable scroll operation, claiming the
nested scroll operation if appropriate.
| |||||||||||
React to a nested scroll operation ending.
| |||||||||||
Implement this method to handle touch screen motion events.
| |||||||||||
Handles scrolling in response to a "page up/down" shortcut press. | |||||||||||
Called when a child of this parent wants focus
| |||||||||||
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
| |||||||||||
Called when a child does not want this parent and its ancestors to
intercept touch events with
onInterceptTouchEvent(MotionEvent) .
| |||||||||||
Call this when something has changed which has invalidated the
layout of this view.
| |||||||||||
Set the scrolled position of your view.
This version also clamps the scrolling to the bounds of our child. | |||||||||||
Indicates this ScrollView whether it should stretch its content height to fill
the viewport or not.
| |||||||||||
Enable or disable nested scrolling for this view.
| |||||||||||
Set whether arrow scrolling will animate its transition.
| |||||||||||
Return true if the pressed state should be delayed for children or descendants of this
ViewGroup.
| |||||||||||
Like
scrollBy(int, int) , but scroll smoothly instead of immediately.
| |||||||||||
Like
scrollTo(int, int) , but scroll smoothly instead of immediately.
| |||||||||||
Begin a nestable scroll operation along the given axes.
| |||||||||||
Stop a nested scroll in progress.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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).
| |||||||||||
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. | |||||||||||
The scroll range of a scroll view is the overall height of all of its children. | |||||||||||
Returns the strength, or intensity, of the bottom faded edge.
| |||||||||||
Returns the strength, or intensity, of the top faded edge.
| |||||||||||
Ask one of the children of this view to measure itself, taking into
account both the MeasureSpec requirements for this view and its padding.
| |||||||||||
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.
| |||||||||||
Called from layout when this view should
assign a size and position to each of its children.
| |||||||||||
Measure the view and its content to determine the measured width and the measured height. | |||||||||||
Called by
overScrollBy(int, int, int, int, int, int, int, int, boolean) to
respond to the results of an over-scroll operation.
| |||||||||||
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.
| |||||||||||
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
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.
| |||||||||||
This is called during layout when the size of this view has changed.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.FrameLayout
| |||||||||||
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.view.ViewParent
| |||||||||||
From interface
android.view.ViewManager
| |||||||||||
From interface
android.graphics.drawable.Drawable.Callback
| |||||||||||
From interface
android.view.KeyEvent.Callback
| |||||||||||
From interface
android.view.accessibility.AccessibilityEventSource
| |||||||||||
From interface
android.support.v4.view.NestedScrollingParent
| |||||||||||
From interface
android.support.v4.view.NestedScrollingChild
|
Defines whether the scrollview should stretch its content to fill the viewport.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol fillViewport
.
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
draw(android.graphics.Canvas)
, onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child | the child view to add |
---|---|
index | the position at which to add the child |
Adds a child view with the specified layout parameters.
Note: do not invoke this method from
draw(android.graphics.Canvas)
, onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child | the child view to add |
---|---|
index | the position at which to add the child |
params | the layout parameters to set on the child |
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
draw(android.graphics.Canvas)
, onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child | the child view to add |
---|
Adds a child view with the specified layout parameters.
Note: do not invoke this method from
draw(android.graphics.Canvas)
, onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child | the child view to add |
---|---|
params | the layout parameters to set on the child |
Handle scrolling in response to an up or down arrow click.
direction | The direction corresponding to the arrow key that was pressed |
---|
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
object.
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.
event | The key event to be dispatched. |
---|
Dispatch a fling to a nested scrolling parent.
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.
velocityX | Horizontal fling velocity in pixels per second |
---|---|
velocityY | Vertical fling velocity in pixels per second |
consumed | true if the child consumed the fling, false otherwise |
Dispatch a fling to a nested scrolling parent before it is processed by this 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.
velocityX | Horizontal fling velocity in pixels per second |
---|---|
velocityY | Vertical fling velocity in pixels per second |
Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
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.
dx | Horizontal scroll distance in pixels |
---|---|
dy | Vertical scroll distance in pixels |
consumed | 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. |
Dispatch one step of a nested scroll in progress.
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.
dxConsumed | Horizontal distance in pixels consumed by this view during this scroll step |
---|---|
dyConsumed | Vertical distance in pixels consumed by this view during this scroll step |
dxUnconsumed | Horizontal scroll distance in pixels not consumed by this view |
dyUnconsumed | Horizontal scroll distance in pixels not consumed by this view |
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. |
Manually render this view (and all of its children) to the given Canvas.
The view must have already done a full layout before this function is
called. When implementing a view, implement
onDraw(android.graphics.Canvas)
instead of overriding this method.
If you do need to override this method, call the superclass version.
canvas | The Canvas to which the View is rendered. |
---|
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.
event | The key event to execute. |
---|
Fling the scroll view
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. |
---|
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: FOCUS_UP
to go the top of the view or
FOCUS_DOWN to go the bottom |
---|
Return the current axes of nested scrolling for this ViewGroup.
A ViewGroup returning something other than SCROLL_AXIS_NONE
is currently
acting as a nested scrolling parent for one or more descendant views in the hierarchy.
Returns true if this view has a nested scrolling parent.
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.
Indicates whether this ScrollView's content is stretched to fill the viewport.
Returns true if nested scrolling is enabled for this 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.
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 before onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after onMeasure(int, int)
.
Implement this method to handle generic motion events.
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 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); }
event | The generic motion event being processed. |
---|
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:
ACTION_CANCEL
, and all further
events will be delivered to your onTouchEvent() method and no longer
appear here.
ev | The motion event being dispatched down the hierarchy. |
---|
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
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.
target | View that initiated the nested scroll |
---|---|
velocityX | Horizontal velocity in pixels per second |
velocityY | Vertical velocity in pixels per second |
consumed | true if the child consumed the fling, false otherwise |
React to a nested fling before the target view consumes it.
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.
target | View that initiated the nested scroll |
---|---|
velocityX | Horizontal velocity in pixels per second |
velocityY | Vertical velocity in pixels per second |
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 invokes
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.
target | View that initiated the nested scroll |
---|---|
dx | Horizontal scroll distance in pixels |
dy | Vertical scroll distance in pixels |
consumed | Output. The horizontal and vertical scroll distance consumed by this parent |
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 to
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.
target | The descendent view controlling the nested scroll |
---|---|
dxConsumed | Horizontal scroll distance in pixels already consumed by target |
dyConsumed | Vertical scroll distance in pixels already consumed by target |
dxUnconsumed | Horizontal scroll distance in pixels not consumed by target |
dyUnconsumed | Vertical scroll distance in pixels not consumed by target |
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 superclass's
implementation of this method if one is present.
child | Direct child of this ViewParent containing target |
---|---|
target | View that initiated the nested scroll |
nestedScrollAxes | Flags consisting of SCROLL_AXIS_HORIZONTAL ,
SCROLL_AXIS_VERTICAL or both |
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
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 onStopNestedScroll(View)
.
child | Direct child of this ViewParent containing target |
---|---|
target | View that initiated the nested scroll |
nestedScrollAxes | Flags consisting of SCROLL_AXIS_HORIZONTAL ,
SCROLL_AXIS_VERTICAL or both |
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 ACTION_UP
or ACTION_CANCEL
event.
Implementations of this method should always call their superclass's implementation of this
method if one is present.
target | View that initiated the nested scroll |
---|
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
performClick()
. This will ensure consistent system behavior,
including:
ACTION_CLICK
when
accessibility features are enabled
ev | The motion event. |
---|
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: FOCUS_UP
to go one page up or
FOCUS_DOWN to go one page down |
---|
Called when a child of this parent wants focus
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 |
Called when a child of this group wants a particular rectangle to be
positioned onto the screen. ViewGroup
s overriding this can trust
that:
ViewGroup
s overriding this should uphold the contract:
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 |
Called when a child does not want this parent and its ancestors to
intercept touch events with
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.
disallowIntercept | True if the child does not want the parent to intercept touch events. |
---|
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 (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.
Set the scrolled position of your view. This will cause a call to
onScrollChanged(int, int, int, int)
and the view will be
invalidated.
This version also clamps the scrolling to the bounds of our child.
x | the x position to scroll to |
---|---|
y | the y position to scroll to |
Indicates this ScrollView whether it should stretch its content height to fill the viewport or not.
fillViewport | True to stretch the content's height to the viewport's boundaries, false otherwise. |
---|
Enable or disable nested scrolling for this 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.
enabled | true to enable nested scrolling, false to disable |
---|
Set whether arrow scrolling will animate its transition.
smoothScrollingEnabled | whether arrow scrolling will animate its transition |
---|
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.
Like scrollBy(int, int)
, but scroll smoothly instead of immediately.
dx | the number of pixels to scroll by on the X axis |
---|---|
dy | the number of pixels to scroll by on the Y axis |
Like scrollTo(int, int)
, but scroll smoothly instead of immediately.
x | the position where to scroll on the X axis |
---|---|
y | the position where to scroll on the Y axis |
Begin a nestable scroll operation along the given axes.
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 ACTION_DOWN
.
In the case of touch scrolling the nested scroll will be terminated automatically in
the same manner as requestDisallowInterceptTouchEvent(boolean)
.
In the event of programmatic scrolling the caller must explicitly call
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 onNestedScroll(View, int, int, int, int)
.
axes | Flags consisting of a combination of SCROLL_AXIS_HORIZONTAL and/or
SCROLL_AXIS_VERTICAL . |
---|
Stop a nested scroll in progress.
Calling this method when a nested scroll is not currently in progress is harmless.
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).
rect | The rect. |
---|
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 computeVerticalScrollRange()
and
computeVerticalScrollExtent()
.
The default offset is the scroll offset of this view.
The scroll range of a scroll view is the overall height of all of its children.
The default range is the drawing height of this view.
Returns the strength, or intensity, of the bottom faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
Returns the strength, or intensity, of the top faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
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.
child | The child to measure |
---|---|
parentWidthMeasureSpec | The width requirements for this view |
parentHeightMeasureSpec | The height requirements for this view |
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.
child | The child to measure |
---|---|
parentWidthMeasureSpec | The width requirements for this view |
widthUsed | Extra space that has been used up by the parent horizontally (possibly by other children of the parent) |
parentHeightMeasureSpec | The height requirements for this view |
heightUsed | Extra space that has been used up by the parent vertically (possibly by other children of the parent) |
Called from layout 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.
changed | This is a new size or position for this view |
---|---|
l | Left position, relative to parent |
t | Top position, relative to parent |
r | Right position, relative to parent |
b | Bottom position, relative to parent |
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by measure(int, int)
and
should be overriden by subclasses to provide accurate and efficient
measurement of their contents.
CONTRACT: When overriding this method, you
must call setMeasuredDimension(int, int)
to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
measure(int, int)
. Calling the superclass'
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 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 (getSuggestedMinimumHeight()
and
getSuggestedMinimumWidth()
).
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 . |
Called by overScrollBy(int, int, int, int, int, int, int, int, boolean)
to
respond to the results of an over-scroll operation.
scrollX | New X scroll value in pixels |
---|---|
scrollY | New Y scroll value in pixels |
clampedX | True if scrollX was clamped to an over-scroll boundary |
clampedY | True if scrollY was clamped to an over-scroll boundary |
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.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|---|
previouslyFocusedRect | 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. |
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by onSaveInstanceState()
. This function will never be called with a
null state.
state | The frozen state that had previously been returned by
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. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.
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.
This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.
w | Current width of this view. |
---|---|
h | Current height of this view. |
oldw | Old width of this view. |
oldh | Old height of this view. |