Build 1.0_r1(from source)

android.widget
Class ScrollView

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.FrameLayout
              extended by android.widget.ScrollView
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, ViewManager, ViewParent

public class ScrollView
extends FrameLayout

Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.

You should never use a ScrollView with a ListView, since ListView takes care of its own scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.

The TextView class also takes care of its own scrolling, so does not require a ScrollView, but using the two together is possible to achieve the effect of a text view within a larger container.

ScrollView only supports vertical scrolling.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.widget.FrameLayout
FrameLayout.LayoutParams
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
 
Fields inherited from class android.widget.FrameLayout
mMeasureAllChildren
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
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, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, 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_FIRST_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_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
ScrollView(Context context)
           
ScrollView(Context context, AttributeSet attrs)
           
ScrollView(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 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.
 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).
protected  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 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()
           
protected  float getTopFadingEdgeStrength()
          Returns the strength, or intensity, of the top faded edge.
 boolean isFillViewport()
          Indicates whether this ScrollView's content is stretched to fill the viewport.
 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.
 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.
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.
 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 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)
          Indicates this ScrollView whether it should stretch its content height to fill the viewport or not.
 void setSmoothScrollingEnabled(boolean smoothScrollingEnabled)
          Set whether arrow scrolling will animate its transition.
 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.
 
Methods inherited from class android.widget.FrameLayout
checkLayoutParams, draw, drawableStateChanged, gatherTransparentRegion, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getConsiderGoneChildrenWhenMeasuring, getForeground, onSizeChanged, setForeground, setForegroundGravity, setMeasureAllChildren, verifyDrawable
 
Methods inherited from class android.view.ViewGroup
addFocusables, addStatesFromChildren, addTouchables, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchFreezeSelfOnly, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawChild, findFocus, findViewTraversal, findViewWithTagTraversal, fitSystemWindows, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChildren, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, showContextMenuForChild, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeVerticalScrollExtent, computeVerticalScrollOffset, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchKeyShortcutEvent, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCreateContextMenu, onDetachedFromWindow, onDraw, onFinishInflate, onFocusChanged, onKeyDown, onKeyMultiple, onKeyShortcut, onKeyUp, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setFrame, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested
 

Constructor Detail

ScrollView

public ScrollView(Context context)

ScrollView

public ScrollView(Context context,
                  AttributeSet attrs)

ScrollView

public ScrollView(Context context,
                  AttributeSet attrs,
                  int defStyle)
Method Detail

getTopFadingEdgeStrength

protected float getTopFadingEdgeStrength()
Description copied from class: View
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.

Overrides:
getTopFadingEdgeStrength in class View
Returns:
the intensity of the top fade as a float between 0.0f and 1.0f

getBottomFadingEdgeStrength

protected float getBottomFadingEdgeStrength()
Description copied from class: 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.

Overrides:
getBottomFadingEdgeStrength in class View
Returns:
the intensity of the bottom fade as a float between 0.0f and 1.0f

getMaxScrollAmount

public int getMaxScrollAmount()
Returns:
The maximum amount this scroll view will scroll in response to an arrow event.

addView

public void addView(View child)
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.

Overrides:
addView in class ViewGroup
Parameters:
child - the child view to add
See Also:
ViewGroup.generateDefaultLayoutParams()

addView

public void addView(View child,
                    int index)
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.

Overrides:
addView in class ViewGroup
Parameters:
child - the child view to add
index - the position at which to add the child
See Also:
ViewGroup.generateDefaultLayoutParams()

addView

public void addView(View child,
                    ViewGroup.LayoutParams params)
Description copied from class: ViewGroup
Adds a child view with the specified layout parameters.

Specified by:
addView in interface ViewManager
Overrides:
addView in class ViewGroup
Parameters:
child - the child view to add
params - the layout parameters to set on the child

addView

public void addView(View child,
                    int index,
                    ViewGroup.LayoutParams params)
Description copied from class: ViewGroup
Adds a child view with the specified layout parameters.

Overrides:
addView in class ViewGroup
Parameters:
child - the child view to add
index - the position at which to add the child
params - the layout parameters to set on the child

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)
Indicates this ScrollView whether it 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

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Description copied from class: FrameLayout

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 overriden 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()).

Overrides:
onMeasure in class FrameLayout
Parameters:
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.
See Also:
View.getMeasuredWidth(), View.getMeasuredHeight(), View.setMeasuredDimension(int, int), View.getSuggestedMinimumHeight(), View.getSuggestedMinimumWidth(), View.MeasureSpec.getMode(int), View.MeasureSpec.getSize(int)

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)
Description copied from class: ViewGroup
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 class ViewGroup
Parameters:
event - The key event to be dispatched.
Returns:
True if the event was handled, false otherwise.

executeKeyEvent

public 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.

Parameters:
event - The key event to execute.
Returns:
Return true if the event was handled, else false.

onInterceptTouchEvent

public boolean onInterceptTouchEvent(MotionEvent ev)
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:

  1. You will receive the down event here.
  2. 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.
  3. 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().
  4. 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 class ViewGroup
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

public boolean onTouchEvent(MotionEvent ev)
Description copied from class: View
Implement this method to handle touch screen motion events.

Overrides:
onTouchEvent in class View
Parameters:
ev - The motion event.
Returns:
True if the event was handled, false otherwise.

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 or View.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 or View.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)
Like View.scrollBy(int, int), but scroll smoothly instead of immediately.

Parameters:
dx - the number of pixels to scroll by on the X axis
dy - the number of pixels to scroll by on the Y axis

smoothScrollTo

public final void smoothScrollTo(int x,
                                 int y)
Like scrollTo(int, int), but scroll smoothly instead of immediately.

Parameters:
x - the position where to scroll on the X axis
y - the position where to scroll on the Y axis

computeVerticalScrollRange

protected int computeVerticalScrollRange()

The scroll range of a scroll view is the overall height of all of its children.

Overrides:
computeVerticalScrollRange in class View
Returns:
the total vertical range represented by the vertical scrollbar

The default range is the drawing height of this view.

See Also:
View.computeVerticalScrollExtent(), View.computeVerticalScrollOffset(), ScrollBarDrawable

measureChild

protected void measureChild(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 class ViewGroup
Parameters:
child - The child to measure
parentWidthMeasureSpec - The width requirements for this view
parentHeightMeasureSpec - The height requirements for this view

measureChildWithMargins

protected void measureChildWithMargins(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 class ViewGroup
Parameters:
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)

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 object.

Overrides:
computeScroll in class View

computeScrollDeltaToGetChildRectOnScreen

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).

Parameters:
rect - The rect.
Returns:
The scroll delta.

requestChildFocus

public void requestChildFocus(View child,
                              View focused)
Description copied from class: ViewGroup
Called when a child of this parent wants focus

Specified by:
requestChildFocus in interface ViewParent
Overrides:
requestChildFocus in class ViewGroup
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

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. This is more expensive than the default ViewGroup implementation, otherwise this behavior might have been made the default.

Overrides:
onRequestFocusInDescendants in class ViewGroup
Parameters:
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.
Returns:
Whether focus was taken.

requestChildRectangleOnScreen

public boolean requestChildRectangleOnScreen(View child,
                                             Rect rectangle,
                                             boolean immediate)
Description copied from class: ViewGroup
Called when a child of this group wants a particular rectangle to be positioned onto the screen. ViewGroups overriding this can trust that:

ViewGroups overriding this should uphold the contract:


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.

Specified by:
requestLayout in interface ViewParent
Overrides:
requestLayout in class View

onLayout

protected void onLayout(boolean changed,
                        int l,
                        int t,
                        int r,
                        int b)
Description copied from class: FrameLayout
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 their children.

Overrides:
onLayout in class FrameLayout
Parameters:
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

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/curor 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 to View.onScrollChanged(int, int, int, int) and the view will be invalidated.

This version also clamps the scrolling to the bounds of our child.

Overrides:
scrollTo in class View
Parameters:
x - the x position to scroll to
y - the y position to scroll to

Build 1.0_r1(from source)

Please submit a feedback, bug or feature