标签:you pos code animator off get lob public adapter
1.从左边滑出动画。
ViewTreeObserver vtobanniang = ivBanniang.getViewTreeObserver();
vtobanniang.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
ivBanniang.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int width = ivBanniang.getWidth();
float[] x = {-width, 0};
ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(ivBanniang, "translationX", x);
objectAnimatorX.setDuration(500);
objectAnimatorX.start();
}
});
2.从左上,左下,右上,右下放大出场动画。
中心点更改为左下角:
mGenderSelectorLinearLayout.setPivotX(0);
mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());
中心点更改为左上角:
mGenderSelectorLinearLayout.setPivotX(0);
mGenderSelectorLinearLayout.setPivotY(0);
中心点更改为右上角:
mGenderSelectorLinearLayout.setPivotX(mGenderSelectorLinearLayout.getWidth()); mGenderSelectorLinearLayout.setPivotY(0);
中心点更改为右下角:
mGenderSelectorLinearLayout.setPivotX(mGenderSelectorLinearLayout.getWidth());
mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());
动画:
public void showGenderSelectorAnimation() { if (mGenderSelectorLinearLayout == null) {return;} mGenderSelectorLinearLayout.post(new Runnable() { @Override public void run() { mGenderSelectorLinearLayout.setPivotX(0); mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight()); ObjectAnimator scaleX = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 0.0f, 1.05f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 0.0f, 1.05f); AnimatorSet set = new AnimatorSet(); set.play(scaleX).with(scaleY); set.setDuration(330); set.start(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (mGenderSelectorLinearLayout == null) { return; } ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 1.05f, 0.98f); ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 1.05f, 0.98f); AnimatorSet set2 = new AnimatorSet(); set2.play(scaleX2).with(scaleY2); set2.setDuration(150); set2.start(); set2.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (mGenderSelectorLinearLayout == null) { return; } ObjectAnimator scaleX3 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 0.98f, 1.0f); ObjectAnimator scaleY3 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 0.98f, 1.0f); AnimatorSet set3 = new AnimatorSet(); set3.play(scaleX3).with(scaleY3); set3.setDuration(300); set3.start(); } }); } }); } }); }
Android View 从左边滑出动画 ,以及从左上,左下,右上,右下放大动画。
标签:you pos code animator off get lob public adapter
原文地址:https://www.cnblogs.com/lixiangyang521/p/13269247.html