zoukankan      html  css  js  c++  java
  • 抛物线动画

    private void jumpToAnim() {

    // 得到两个按钮的位置,和宽高,设置收藏按钮和收藏文件夹之间的抛物线动画

    final int[] location1s;

    final int[] location2s;

        location1s = new int[2];

        llShouCang.getLocationInWindow(location1s);

        location2s = new int[2];

        rlFavorites.getLocationOnScreen(location2s);

        location1s[0]=location1s[0]+llShouCang.getMeasuredWidth()/8;

        location2s[0]=location2s[0]+rlFavorites.getMeasuredWidth()/2;

    ValueAnimator valueAnimator = new ValueAnimator().ofFloat((float)(location1s[0]+0.0),(float)(location2s[0]+0.0));

    valueAnimator.setDuration(1000);

    // valueAnimator.setObjectValues(new PointF(0, 0), new PointF(200, 200));

    valueAnimator.setInterpolator(new DecelerateInterpolator());;

    valueAnimator.start();

    ivVehicleLike.setVisibility(View.VISIBLE);

    new Handler().postDelayed(new Runnable() {

    @Override

    public void run() {

    ivVehicleLike.setVisibility(View.GONE);

    }

    }, 900);

    valueAnimator.addUpdateListener(new AnimatorUpdateListener() {

    @Override

    public void onAnimationUpdate(ValueAnimator animation) {

    Float x=  (Float) animation.getAnimatedValue();

    Float y;

    int midX=(location2s[0]+location1s[0])/2;

    int halfLength=(location2s[0]-location1s[0])/2;

    // y=location1s[1]-midX*midX/30+(x-midX)*(x-midX)/30;

    y=location1s[1]+(x-midX)*(x-midX)/30-halfLength*halfLength/30-llShouCang.getMeasuredHeight()/2;

    ivVehicleLike.setX(x);

    ivVehicleLike.setY(y);

    // ivVehicleLike.setX(x);

    // ivVehicleLike.setY(y);

    }

    });

    }

  • 相关阅读:
    zabbix笔记之zabbix-agent 安装
    Bat脚本处理ftp超强案例解说
    tidb集群部署
    NPM是node.js软件包的管理器
    一、安装vue-cli(当前版本是4.x)(只需安装一次,后面永久使用)
    二十四、ref获取DOM
    二十三、watch监听
    二十二、computed计算属性
    二十一、todolist案例开发
    二十、双向绑定原理
  • 原文地址:https://www.cnblogs.com/wangzehuaw/p/4494366.html
Copyright © 2011-2022 走看看