当前位置: 首页>>代码示例>>Java>>正文


Java DynamicAnimation类代码示例

本文整理汇总了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();
}
 
开发者ID:coderwjq,项目名称:ZhaZhaShop,代码行数:24,代码来源:SplashActivity.java

示例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;
}
 
开发者ID:richakhanna,项目名称:physicsbasedanimation,代码行数:30,代码来源:TranslateFlingAnimationActivity.java

示例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();
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:36,代码来源:BottomSheet.java


注:本文中的android.support.animation.DynamicAnimation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。