/** * 按钮浮动动画 * * @param view */ @SuppressLint("WrongConstant") private void initAnimation(View view) { List<Animator> animators = new ArrayList<>(); switch (view.getId()) { case R.id.iv_expo_comprofile: translationXAnim = ObjectAnimator.ofFloat(view, "translationX", -6.0f, 6.0f, -6.0f); translationYAnim = ObjectAnimator.ofFloat(view, "translationY", -3.0f, 3.0f, -3.0f); break; case R.id.iv_expo_prodispaly: translationXAnim = ObjectAnimator.ofFloat(view, "translationX", 6.0f, -6.0f, 6.0f); translationYAnim = ObjectAnimator.ofFloat(view, "translationY", -3.0f, 3.0f, -3.0f); break; case R.id.iv_expo_recreation: translationXAnim = ObjectAnimator.ofFloat(view, "translationX", -6.0f, 6.0f, -6.0f); translationYAnim = ObjectAnimator.ofFloat(view, "translationY", 3.0f, -3.0f, 3.0f); break; default: break; } translationXAnim.setDuration(2000); translationXAnim.setRepeatCount(ValueAnimator.INFINITE); translationXAnim.setRepeatMode(ValueAnimator.INFINITE); translationXAnim.start(); animators.add(translationXAnim); translationYAnim.setDuration(1500); translationYAnim.setRepeatCount(ValueAnimator.INFINITE); translationYAnim.setRepeatMode(ValueAnimator.INFINITE); translationYAnim.start(); animators.add(translationYAnim); AnimatorSet btnSexAnimatorSet = new AnimatorSet(); btnSexAnimatorSet.playTogether(animators); btnSexAnimatorSet.setStartDelay(10000); btnSexAnimatorSet.start(); }
好用的漂浮、浮动动画
最新推荐文章于 2022-09-28 15:38:06 发布