|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.simonvt.menudrawer.Scroller
public class Scroller
This class encapsulates scrolling. The duration of the scroll can be passed in the constructor and specifies the maximum time that the scrolling animation should take. Past this time, the scrolling is automatically moved to its final stage and computeScrollOffset() will always return false to indicate that scrolling is over.
| Constructor Summary | |
|---|---|
Scroller(android.content.Context context)
Create a Scroller with the default duration and interpolator. |
|
Scroller(android.content.Context context,
android.view.animation.Interpolator interpolator)
Create a Scroller with the specified interpolator. |
|
Scroller(android.content.Context context,
android.view.animation.Interpolator interpolator,
boolean flywheel)
Create a Scroller with the specified interpolator. |
|
| Method Summary | |
|---|---|
void |
abortAnimation()
Stops the animation. |
boolean |
computeScrollOffset()
Call this when you want to know the new location. |
void |
extendDuration(int extend)
Extend the scroll animation. |
void |
fling(int startX,
int startY,
int velocityX,
int velocityY,
int minX,
int maxX,
int minY,
int maxY)
Start scrolling based on a fling gesture. |
void |
forceFinished(boolean finished)
Force the finished field to a particular value. |
float |
getCurrVelocity()
Returns the current velocity. |
int |
getCurrX()
Returns the current X offset in the scroll. |
int |
getCurrY()
Returns the current Y offset in the scroll. |
int |
getDuration()
Returns how long the scroll event will take, in milliseconds. |
int |
getFinalX()
Returns where the scroll will end. |
int |
getFinalY()
Returns where the scroll will end. |
int |
getStartX()
Returns the start X offset in the scroll. |
int |
getStartY()
Returns the start Y offset in the scroll. |
boolean |
isFinished()
Returns whether the scroller has finished scrolling. |
boolean |
isScrollingInDirection(float xvel,
float yvel)
|
void |
setFinalX(int newX)
Sets the final position (X) for this scroller. |
void |
setFinalY(int newY)
Sets the final position (Y) for this scroller. |
void |
setFriction(float friction)
The amount of friction applied to flings. |
void |
startScroll(int startX,
int startY,
int dx,
int dy)
Start scrolling by providing a starting point and the distance to travel. |
void |
startScroll(int startX,
int startY,
int dx,
int dy,
int duration)
Start scrolling by providing a starting point and the distance to travel. |
int |
timePassed()
Returns the time elapsed since the beginning of the scrolling. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Scroller(android.content.Context context)
public Scroller(android.content.Context context,
android.view.animation.Interpolator interpolator)
public Scroller(android.content.Context context,
android.view.animation.Interpolator interpolator,
boolean flywheel)
| Method Detail |
|---|
public final void setFriction(float friction)
ViewConfiguration.getScrollFriction().
friction - A scalar dimension-less value representing the coefficient of
friction.public final boolean isFinished()
public final void forceFinished(boolean finished)
finished - The new finished value.public final int getDuration()
public final int getCurrX()
public final int getCurrY()
public float getCurrVelocity()
public final int getStartX()
public final int getStartY()
public final int getFinalX()
public final int getFinalY()
public boolean computeScrollOffset()
public void startScroll(int startX,
int startY,
int dx,
int dy)
startX - Starting horizontal scroll offset in pixels. Positive
numbers will scroll the content to the left.startY - Starting vertical scroll offset in pixels. Positive numbers
will scroll the content up.dx - Horizontal distance to travel. Positive numbers will scroll the
content to the left.dy - Vertical distance to travel. Positive numbers will scroll the
content up.
public void startScroll(int startX,
int startY,
int dx,
int dy,
int duration)
startX - Starting horizontal scroll offset in pixels. Positive
numbers will scroll the content to the left.startY - Starting vertical scroll offset in pixels. Positive numbers
will scroll the content up.dx - Horizontal distance to travel. Positive numbers will scroll the
content to the left.dy - Vertical distance to travel. Positive numbers will scroll the
content up.duration - Duration of the scroll in milliseconds.
public void fling(int startX,
int startY,
int velocityX,
int velocityY,
int minX,
int maxX,
int minY,
int maxY)
startX - Starting point of the scroll (X)startY - Starting point of the scroll (Y)velocityX - Initial velocity of the fling (X) measured in pixels per
second.velocityY - Initial velocity of the fling (Y) measured in pixels per
secondminX - Minimum X value. The scroller will not scroll past this
point.maxX - Maximum X value. The scroller will not scroll past this
point.minY - Minimum Y value. The scroller will not scroll past this
point.maxY - Maximum Y value. The scroller will not scroll past this
point.public void abortAnimation()
forceFinished(boolean),
aborting the animating cause the scroller to move to the final x and y
position
forceFinished(boolean)public void extendDuration(int extend)
setFinalX(int) or setFinalY(int).
extend - Additional time to scroll in milliseconds.setFinalX(int),
setFinalY(int)public int timePassed()
public void setFinalX(int newX)
newX - The new X offset as an absolute distance from the origin.extendDuration(int),
setFinalY(int)public void setFinalY(int newY)
newY - The new Y offset as an absolute distance from the origin.extendDuration(int),
setFinalX(int)
public boolean isScrollingInDirection(float xvel,
float yvel)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||