码迷,mamicode.com
首页 > 移动开发 > 详细

Android动画

时间:2015-11-02 01:30:40      阅读:329      评论:0      收藏:0      [点我收藏+]

标签:

	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动画

标签:

原文地址:http://www.cnblogs.com/wanghongwei/p/4929101.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!