Android动画
2015-11-02 00:50
281 查看
private void showInAnim(final View view, final View backgroundview) { DisplayMetrics dm = getResources().getDisplayMetrics(); float w_screen = dm.widthPixels; final float scale = w_screen / (w_screen - (float) Common.dip2px(this, 20)); AnimatorSet set = new AnimatorSet(); ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.0f, scale); scaleX.setDuration(220); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.0f, scale); scaleY.setDuration(220); ObjectAnimator backgroundColor = ObjectAnimator.ofInt(backgroundview, "backgroundColor", Color.parseColor("#00000000"), Color.parseColor("#7f000000")); backgroundColor.setDuration(220); backgroundColor.setEvaluator(new ArgbEvaluator()); ObjectAnimator backgroundColorOne = ObjectAnimator.ofInt(comment_bg_one, "backgroundColor", Color.parseColor("#00000000"), Color.parseColor("#7f000000")); backgroundColorOne.setDuration(220); backgroundColorOne.setEvaluator(new ArgbEvaluator()); ObjectAnimator backgroundColorTwo = ObjectAnimator.ofInt(comment_bg_two, "backgroundColor", Color.parseColor("#00000000"), Color.parseColor("#7f000000")); backgroundColorTwo.setDuration(220); backgroundColorTwo.setEvaluator(new ArgbEvaluator()); ObjectAnimator translationX = ObjectAnimator.ofFloat(view, "translationX", pivotX - getResources().getDisplayMetrics().widthPixels / 2, 0.0f); translationX.setDuration(220); ObjectAnimator translationY = ObjectAnimator.ofFloat(view, "translationY", pivotY - getResources().getDisplayMetrics().heightPixels / 2, 0.0f); translationY.setDuration(220); ObjectAnimator scaleXhui = ObjectAnimator.ofFloat(view, "scaleX", scale, 1.0f); scaleXhui.setDuration(120); ObjectAnimator scaleYhui = ObjectAnimator.ofFloat(view, "scaleY", scale, 1.0f); scaleYhui.setDuration(120); set.playTogether(scaleX, scaleY, backgroundColor, backgroundColorOne, backgroundColorTwo, translationX, translationY); set.play(scaleXhui).with(scaleYhui).after(scaleX); set.setInterpolator(new DecelerateInterpolator()); set.start(); set.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator arg0) { } @Override public void onAnimationRepeat(Animator arg0) { } @Override public void onAnimationEnd(Animator arg0) { loadData(true); } @Override public void onAnimationCancel(Animator arg0) { } }); } private void showOutAnim(View view, View backgroundview) { int[] location = new int[2]; content.getLocationOnScreen(location); layoutY = location[1] + content.getHeight() / 2; AnimatorSet set = new AnimatorSet(); ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.0f); ObjectAnimator translationX = ObjectAnimator.ofFloat(view, "translationX", 0.0f, pivotX - getResources().getDisplayMetrics().widthPixels / 2); ObjectAnimator translationY = ObjectAnimator.ofFloat(view, "translationY", 0.0f, pivotY - layoutY); ObjectAnimator backgroundColor = ObjectAnimator.ofInt(backgroundview, "backgroundColor", Color.parseColor("#7f000000"), Color.parseColor("#00000000")); backgroundColor.setEvaluator(new ArgbEvaluator()); ObjectAnimator backgroundColorOne = ObjectAnimator.ofInt(comment_bg_one, "backgroundColor", Color.parseColor("#7f000000"), Color.parseColor("#00000000")); backgroundColorOne.setEvaluator(new ArgbEvaluator()); ObjectAnimator backgroundColorTwo = ObjectAnimator.ofInt(comment_bg_two, "backgroundColor", Color.parseColor("#7f000000"), Color.parseColor("#00000000")); backgroundColorTwo.setEvaluator(new ArgbEvaluator()); set.play(scaleX).with(scaleY).with(translationX).with(translationY).with(backgroundColor).with(backgroundColorOne).with(backgroundColorTwo); set.setDuration(240).setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator arg0) { } @Override public void onAnimationRepeat(Animator arg0) { } @Override public void onAnimationEnd(Animator arg0) { DingDetailActivity.this.finish(); } @Override public void onAnimationCancel(Animator arg0) { } }); set.start(); }
相关文章推荐
- android添加触摸事件
- Android 开发中,有哪些坑需要注意?
- Android开发涉及有点概念&相关知识点(待写)
- 在Android library中不能使用switch-case语句访问资源ID的原因分析及解决方案
- android sqlite应用优化(资料整理)
- android退出应用程序
- Android 下获取手机通讯录信息
- AutoHomeRefreshListView仿汽车之家下拉刷新 《IT蓝豹》
- Android之ImageSwitcher控件概述
- 安卓开发中EditText的焦点改变处理(获取焦点和失去焦点交互变化)
- Android Socket 发送广播包的那些坑
- Android-setContentView的二次理解
- Android中监听ListView滑动到底部
- 反编译Android 语法
- android串口通信——android-serialport-api
- android串口通信——android-serialport-api
- Android学习路线指南
- Android屏幕适配
- Android NDK开发(二)——JNI访问和引用JAVA对象
- android 锁屏程序开发