Android 實現 遮罩動畫效果
阿新 • • 發佈:2019-02-07
為了實現遮罩效果動畫。android本身沒有提供api ,需要自己動手實現。
將view和view的parentLy進行相反方向動畫即可實現該效果:
AnimatorSet animatorSet = new AnimatorSet();
//背景layout
ObjectAnimator bgLy = ObjectAnimator.ofFloat(loginShowContainerLy,
"translationX", -measureWidth(loginShowContainerLy), 0.0f);
bgLy.setDuration(showLoginBgEnterTime);
bgLy.setInterpolator(new LinearInterpolator());
ObjectAnimator view = ObjectAnimator.ofFloat(loginShowView,
"translationX", measureWidth(loginShowView), 0.0f);
viewLy.setDuration(showLoginBgEnterTime);
viewLy.setInterpolator(new LinearInterpolator());
animatorSet.play (bgLy).with(view);
animatorSet.start();