本文整理汇总了Java中android.support.animation.DynamicAnimation类的典型用法代码示例。如果您正苦于以下问题:Java DynamicAnimation类的具体用法?Java DynamicAnimation怎么用?Java DynamicAnimation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DynamicAnimation类属于android.support.animation包,在下文中一共展示了DynamicAnimation类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initIconAnimation
import android.support.animation.DynamicAnimation; //导入依赖的package包/类
/**
* 初始化开始动画
*/
private void initIconAnimation() {
int screenH = DensityUtil.getScreenH(this);
SpringForce springForce = new SpringForce()
.setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
.setStiffness(SpringForce.STIFFNESS_VERY_LOW)
.setFinalPosition(0);
SpringAnimation springAnimation = new SpringAnimation(mCivIcon, DynamicAnimation.TRANSLATION_Y)
.setSpring(springForce)
.setStartValue(screenH);
springAnimation.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
@Override
public void onAnimationEnd(DynamicAnimation animation, boolean canceled, float value, float velocity) {
initTextAnimation();
}
});
springAnimation.start();
}
示例2: onFling
import android.support.animation.DynamicAnimation; //导入依赖的package包/类
@Override
public boolean onFling(MotionEvent downEvent, MotionEvent moveEvent, float velocityX, float velocityY) {
//downEvent : when user puts his finger down on the view
//moveEvent : when user lifts his finger at the end of the movement
float distanceInX = Math.abs(moveEvent.getRawX() - downEvent.getRawX());
float distanceInY = Math.abs(moveEvent.getRawY() - downEvent.getRawY());
mTvFlingDistance.setText("distanceInX : " + distanceInX + "\n" + "distanceInY : " + distanceInY);
if (distanceInX > MIN_DISTANCE_MOVED) {
//Fling Right/Left
FlingAnimation flingX = new FlingAnimation(mViewTobeFlung, DynamicAnimation.TRANSLATION_X);
flingX.setStartVelocity(velocityX)
.setMinValue(MIN_TRANSLATION) // minimum translationX property
.setMaxValue(maxTranslationX) // maximum translationX property
.setFriction(FRICTION)
.start();
} else if (distanceInY > MIN_DISTANCE_MOVED) {
//Fling Down/Up
FlingAnimation flingY = new FlingAnimation(mViewTobeFlung, DynamicAnimation.TRANSLATION_Y);
flingY.setStartVelocity(velocityY)
.setMinValue(MIN_TRANSLATION) // minimum translationY property
.setMaxValue(maxTranslationY) // maximum translationY property
.setFriction(FRICTION)
.start();
}
return true;
}
示例3: animateSettle
import android.support.animation.DynamicAnimation; //导入依赖的package包/类
void animateSettle(int targetOffset, float initialVelocity) {
if (settling) return;
if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) {
if (targetOffset >= dismissOffset) {
dispatchDismissCallback();
}
return;
}
settling = true;
final boolean dismissing = targetOffset == dismissOffset;
// if we're dismissing, we don't want the view to decelerate as it reaches the bottom
// so set a target position that actually overshoots a little
final float finalPosition = dismissing ? dismissOffset * 1.1f : targetOffset;
SpringAnimation anim = new SpringAnimation(
sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, finalPosition)
.setStartValue(sheetOffsetHelper.getTopAndBottomOffset())
.setStartVelocity(initialVelocity)
.setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS);
anim.getSpring()
.setStiffness(SETTLE_STIFFNESS)
.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY);
anim.addEndListener((animation, canceled, value, velocity) -> {
dispatchPositionChangedCallback();
if (dismissing) {
dispatchDismissCallback();
}
settling = false;
});
if (callbacks != null && !callbacks.isEmpty()) {
anim.addUpdateListener((animation, value, velocity) -> dispatchPositionChangedCallback());
}
anim.start();
}