public final class EdgeEffectCompat
extends Object
| java.lang.Object | |
| android.support.v4.widget.EdgeEffectCompat | |
帮助用户以向后兼容的方式访问API级别4之后引入的EdgeEffect 。 该类用于在支持它的平台版本上访问EdgeEffect 。 在较旧的平台上运行时,将导致无操作。 它应该被希望在滚动容器边缘使用标准Android视觉效果的视图所使用。
Public constructors |
|
|---|---|
EdgeEffectCompat(Context context) 使用给定的上下文构造一个新的EdgeEffect主题。 |
|
公共方法(Public methods) |
|
|---|---|
boolean |
draw(Canvas canvas) 画到提供的画布上。 |
void |
finish() 立即完成当前动画。 |
boolean |
isFinished() 报告EdgeEffectCompat的动画是否完成。 |
boolean |
onAbsorb(int velocity) 当效应以给定的速度吸收冲击时调用。 |
boolean |
onPull(float deltaDistance) 此方法已弃用。 使用 |
boolean |
onPull(float deltaDistance, float displacement) 一个视图应该在用户将内容从边缘拉开时调用它。 |
boolean |
onRelease() 在被拉动后释放对象时调用。 |
void |
setSize(int width, int height) 以像素为单位设置此边缘效果的大小。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
EdgeEffectCompat (Context context)
使用给定的上下文构造一个新的EdgeEffect主题。
注意:在不支持EdgeEffect的平台版本上,新构建对象上的所有操作都将被模拟/无操作。
| 参数(Parameters) | |
|---|---|
context |
Context: Context to use for theming the effect |
boolean draw (Canvas canvas)
画到提供的画布上。 假定画布已相应地旋转并且大小已设置。 效果将绘制从X = 0到X =宽度的整个宽度,从Y = 0开始并延伸到高度的一些因子<1.f。
| 参数(Parameters) | |
|---|---|
canvas |
Canvas: Canvas to draw into |
| 返回(Returns) | |
|---|---|
boolean |
true if drawing should continue beyond this frame to continue the animation |
boolean isFinished ()
报告EdgeEffectCompat的动画是否完成。 如果在调用draw(Canvas)之后此方法返回false,则主机小部件应安排另一个绘制过程以继续动画。
| 返回(Returns) | |
|---|---|
boolean |
true if animation is finished, false if drawing should continue on the next frame. |
boolean onAbsorb (int velocity)
当效应以给定的速度吸收冲击时调用。 在投掷物到达滚动边界时使用。
当使用 Scroller或 OverScroller ,方法 getCurrVelocity将提供在此使用的合理近似值。
| 参数(Parameters) | |
|---|---|
velocity |
int: Velocity at impact in pixels per second. |
| 返回(Returns) | |
|---|---|
boolean |
true if the host view should invalidate, false if it should not. |
boolean onPull (float deltaDistance)
此方法已弃用。
使用onPull(float, float)
一个视图应该在用户将内容从边缘拉开时调用它。 这将更新当前视觉效果及其相关动画的状态。 如果此方法返回true并且相应地绘制结果,则宿主视图应始终为invalidate() 。
| 参数(Parameters) | |
|---|---|
deltaDistance |
float: Change in distance since the last call. Values may be 0 (no change) to 1.f (full length of the view) or negative values to express change back toward the edge reached to initiate the effect. |
| 返回(Returns) | |
|---|---|
boolean |
true if the host view should call invalidate, false if it should not. |
boolean onPull (float deltaDistance,
float displacement)
一个视图应该在用户将内容从边缘拉开时调用它。 这将更新当前视觉效果及其相关动画的状态。 如果此方法返回true并且相应地绘制结果,则主机视图应始终为invalidate() 。
| 参数(Parameters) | |
|---|---|
deltaDistance |
float: Change in distance since the last call. Values may be 0 (no change) to 1.f (full length of the view) or negative values to express change back toward the edge reached to initiate the effect. |
displacement |
float: The displacement from the starting side of the effect of the point initiating the pull. In the case of touch this is the finger position. Values may be from 0-1. |
| 返回(Returns) | |
|---|---|
boolean |
true if the host view should call invalidate, false if it should not. |
boolean onRelease ()
在被拉动后释放对象时调用。 这将开始效果的“衰退”阶段。 在调用此方法后,如果此方法返回true,则主机视图应为invalidate() ,从而相应地绘制结果。
| 返回(Returns) | |
|---|---|
boolean |
true if the host view should invalidate, false if it should not. |
void setSize (int width,
int height)
以像素为单位设置此边缘效果的大小。
| 参数(Parameters) | |
|---|---|
width |
int: Effect width in pixels |
height |
int: Effect height in pixels |