|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.view.View
android.view.ViewGroup
android.widget.FrameLayout
android.widget.ScrollView
public class ScrollView
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 |
| 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 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 |
|---|
public ScrollView(Context context)
public ScrollView(Context context,
AttributeSet attrs)
public ScrollView(Context context,
AttributeSet attrs,
int defStyle)
| Method Detail |
|---|
protected float getTopFadingEdgeStrength()
View
getTopFadingEdgeStrength in class Viewprotected float getBottomFadingEdgeStrength()
View
getBottomFadingEdgeStrength in class Viewpublic int getMaxScrollAmount()
public void addView(View child)
ViewGroup
addView in class ViewGroupchild - the child view to addViewGroup.generateDefaultLayoutParams()
public void addView(View child,
int index)
ViewGroup
addView in class ViewGroupchild - the child view to addindex - the position at which to add the childViewGroup.generateDefaultLayoutParams()
public void addView(View child,
ViewGroup.LayoutParams params)
ViewGroup
addView in interface ViewManageraddView in class ViewGroupchild - the child view to addparams - the layout parameters to set on the child
public void addView(View child,
int index,
ViewGroup.LayoutParams params)
ViewGroup
addView in class ViewGroupchild - the child view to addindex - the position at which to add the childparams - the layout parameters to set on the childpublic boolean isFillViewport()
public void setFillViewport(boolean fillViewport)
fillViewport - True to stretch the content's height to the viewport's
boundaries, false otherwise.public boolean isSmoothScrollingEnabled()
public void setSmoothScrollingEnabled(boolean smoothScrollingEnabled)
smoothScrollingEnabled - whether arrow scrolling will animate its transition
protected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
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()).
onMeasure in class FrameLayoutwidthMeasureSpec - horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec.heightMeasureSpec - vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec.View.getMeasuredWidth(),
View.getMeasuredHeight(),
View.setMeasuredDimension(int, int),
View.getSuggestedMinimumHeight(),
View.getSuggestedMinimumWidth(),
View.MeasureSpec.getMode(int),
View.MeasureSpec.getSize(int)public boolean dispatchKeyEvent(KeyEvent event)
ViewGroup
dispatchKeyEvent in class ViewGroupevent - The key event to be dispatched.
public boolean executeKeyEvent(KeyEvent event)
event - The key event to execute.
public boolean onInterceptTouchEvent(MotionEvent ev)
ViewGroupUsing this function takes some care, as it has a fairly complicated
interaction with View.onTouchEvent(MotionEvent), and using it requires implementing
that method as well as this one in the correct way. Events will be
received in the following order:
MotionEvent.ACTION_CANCEL, and all further
events will be delivered to your onTouchEvent() method and no longer
appear here.
onInterceptTouchEvent in class ViewGroupev - The motion event being dispatched down the hierarchy.
public boolean onTouchEvent(MotionEvent ev)
View
onTouchEvent in class Viewev - The motion event.
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.
direction - the scroll direction: View.FOCUS_UP
to go one page up or
View.FOCUS_DOWN to go one page down
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.
direction - the scroll direction: View.FOCUS_UP
to go the top of the view or
View.FOCUS_DOWN to go the bottom
public boolean arrowScroll(int direction)
direction - The direction corresponding to the arrow key that was
pressed
public final void smoothScrollBy(int dx,
int dy)
View.scrollBy(int, int), but scroll smoothly instead of immediately.
dx - the number of pixels to scroll by on the X axisdy - the number of pixels to scroll by on the Y axis
public final void smoothScrollTo(int x,
int y)
scrollTo(int, int), but scroll smoothly instead of immediately.
x - the position where to scroll on the X axisy - the position where to scroll on the Y axisprotected int computeVerticalScrollRange()
The scroll range of a scroll view is the overall height of all of its children.
computeVerticalScrollRange in class ViewThe default range is the drawing height of this view.
View.computeVerticalScrollExtent(),
View.computeVerticalScrollOffset(),
ScrollBarDrawable
protected void measureChild(View child,
int parentWidthMeasureSpec,
int parentHeightMeasureSpec)
ViewGroup
measureChild in class ViewGroupchild - The child to measureparentWidthMeasureSpec - The width requirements for this viewparentHeightMeasureSpec - The height requirements for this view
protected void measureChildWithMargins(View child,
int parentWidthMeasureSpec,
int widthUsed,
int parentHeightMeasureSpec,
int heightUsed)
ViewGroup
measureChildWithMargins in class ViewGroupchild - The child to measureparentWidthMeasureSpec - The width requirements for this viewwidthUsed - Extra space that has been used up by the parent
horizontally (possibly by other children of the parent)parentHeightMeasureSpec - The height requirements for this viewheightUsed - Extra space that has been used up by the parent
vertically (possibly by other children of the parent)public void computeScroll()
ViewScroller
object.
computeScroll in class Viewprotected int computeScrollDeltaToGetChildRectOnScreen(Rect rect)
rect - The rect.
public void requestChildFocus(View child,
View focused)
ViewGroup
requestChildFocus in interface ViewParentrequestChildFocus in class ViewGroupchild - 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
protected boolean onRequestFocusInDescendants(int direction,
Rect previouslyFocusedRect)
ViewGroup
implementation, otherwise this behavior might have been made the default.
onRequestFocusInDescendants in class ViewGroupdirection - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHTpreviouslyFocusedRect - The rectangle (in this View's coordinate system)
to give a finer grained hint about where focus is coming from. May be null
if there is no hint.
public boolean requestChildRectangleOnScreen(View child,
Rect rectangle,
boolean immediate)
ViewGroupViewGroups overriding this can trust
that:
ViewGroups overriding this should uphold the contract:
requestChildRectangleOnScreen in class ViewGroupchild - 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
public void requestLayout()
View
requestLayout in interface ViewParentrequestLayout in class View
protected void onLayout(boolean changed,
int l,
int t,
int r,
int b)
FrameLayout
onLayout in class FrameLayoutchanged - This is a new size or position for this viewl - Left position, relative to parentt - Top position, relative to parentr - Right position, relative to parentb - Bottom position, relative to parentpublic void fling(int velocityY)
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.
public void scrollTo(int x,
int y)
View.onScrollChanged(int, int, int, int) and the view will be
invalidated.
This version also clamps the scrolling to the bounds of our child.
scrollTo in class Viewx - the x position to scroll toy - the y position to scroll to
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||