• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SpringAnimation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.support.animation.SpringAnimation的典型用法代码示例。如果您正苦于以下问题:Java SpringAnimation类的具体用法?Java SpringAnimation怎么用?Java SpringAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SpringAnimation类属于android.support.animation包,在下文中一共展示了SpringAnimation类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initIconAnimation

import android.support.animation.SpringAnimation; //导入依赖的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: animateSettle

import android.support.animation.SpringAnimation; //导入依赖的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


示例3: onCreate

import android.support.animation.SpringAnimation; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mVelocityTracker = VelocityTracker.obtain();

    final ImageView droid = (ImageView) findViewById(R.id.droid);
    findViewById(android.R.id.content).setOnTouchListener(new View.OnTouchListener() {
        private final Rect mRect = new Rect();

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    mDownX = event.getX();
                    mDownY = event.getY();
                    mVelocityTracker.addMovement(event);
                    return true;
                case MotionEvent.ACTION_MOVE:
                    float x = event.getX();
                    float y = event.getY();
                    droid.getHitRect(mRect);
                    if (mRect.contains((int) x, (int) y)) {
                        droid.setTranslationX(x - mDownX);
                        droid.setTranslationY(y - mDownY);
                        mVelocityTracker.addMovement(event);
                    }
                    return true;
                case MotionEvent.ACTION_UP:
                    // fall-thru
                case MotionEvent.ACTION_CANCEL:
                    mVelocityTracker.computeCurrentVelocity(1000);
                    if (droid.getTranslationX() != 0) {
                        SpringAnimation animX = new SpringAnimation(droid, SpringAnimation.TRANSLATION_X, 0);
                        animX.getSpring().setStiffness(getStiffness());
                        animX.getSpring().setDampingRatio(getDamping());
                        animX.setStartVelocity(mVelocityTracker.getXVelocity());
                        animX.start();
                    }
                    if (droid.getTranslationY() != 0) {
                        SpringAnimation animY = new SpringAnimation(droid, SpringAnimation.TRANSLATION_Y, 0);
                        animY.getSpring().setStiffness(getStiffness());
                        animY.getSpring().setDampingRatio(getDamping());
                        animY.setStartVelocity(mVelocityTracker.getYVelocity());
                        animY.start();
                    }
                    mVelocityTracker.clear();
                    return true;
            }
            return false;
        }
    });
}
 
开发者ID:mightyfrog,项目名称:Dynamic-Animation-Sample,代码行数:55,代码来源:MainActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Guild类代码示例发布时间:2022-05-22
下一篇:
Java LocalServiceBindingException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap