close
本篇來簡單示範如何讓一個底線活潑的動起來,讓使用者直接感受到切換的感覺
// 由於是要同時移動以及縮放,所以用一個animatorSet包起來 var animatorSet = AnimatorSet() //設定兩種動畫: 移動translationX, 縮放:scaleX animatorSet.playTogether( ObjectAnimator.ofFloat(mUnderLine, "translationX", targetX).setDuration(300), ObjectAnimator.ofFloat(mUnderLine, "scaleX", 1f, 0.5f).setDuration(300) ) // 設定動畫移動的加速度 (快->慢) animatorSet.interpolator = AccelerateDecelerateInterpolator() animatorSet.start()
Reference:
https://www.itread01.com/content/1560911822.html
全站熱搜