zoukankan      html  css  js  c++  java
  • Android为TV端助力 电影栏目移动到底部或者顶部时抖动动画

    1 移动到底部上下抖动
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(holder.itemView,"translationX",0,0);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(holder.itemView,"translationY",0,10,15,10,0);
    AnimatorSet set =new AnimatorSet();
    set.setDuration(1000);
    set.setInterpolator(new SpringScaleInterpolator(0.4f));
    set.playTogether(animatorX,animatorY);
    set.start();
    2,移动左边或者右边边缘,左右抖动
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(holder.itemView,"translationX",0,10,15,10,0);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(holder.itemView,"translationY",0,0);
    AnimatorSet set =new AnimatorSet();
    set.setDuration(1000);
    set.setInterpolator(new SpringScaleInterpolator(0.4f));
    set.playTogether(animatorX,animatorY);
    set.start();
    
    
    public class SpringScaleInterpolator implements Interpolator {
    //弹性因数
    private float factor;

    public SpringScaleInterpolator(float factor) {
    this.factor = factor;
    }

    @Override
    public float getInterpolation(float input) {

    return (float) (Math.pow(2, -10 * input) * Math.sin((input - factor / 4) * (2 * Math.PI) / factor) + 1);
    }

    }



  • 相关阅读:
    依赖注入简单解释
    设计模式
    Git 命令使用
    手机版自适应
    自定义属性的添加
    innerText Textcontent浏览器兼容代码
    获取间的内容
    密码长度为6-10的判断
    模拟输入框
    排他功能
  • 原文地址:https://www.cnblogs.com/xiaoxiaing/p/7809279.html
Copyright © 2011-2022 走看看