网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Android属性动画备忘nineold-创新互联

项目开发偶尔会用到动画,每次都得找以前的代码复制,太麻烦了,但又记不住,只好写在这.

创新互联是一家专注于网站设计、成都网站建设与策划设计,灵寿网站建设哪家好?创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:灵寿等地区。灵寿做网站价格咨询:18982081108
                ObjectAnimator.ofFloat(view, "translationX", 0, 50, -50, 0).setDuration(duration).start();//位移
                ObjectAnimator.ofFloat(view, "translationY", 0, 50, -50, 0).setDuration(duration).start();
                ObjectAnimator.ofFloat(view, "scaleX", 1, 2, 1).setDuration(duration).start();//缩放
                ObjectAnimator.ofFloat(view, "scaleY", 1, 2, 1).setDuration(duration).start();
                ObjectAnimator.ofFloat(view, "alpha", 1, 0, 1).setDuration(duration).start();//透明度
                ObjectAnimator.ofFloat(view, "rotationX", 0, 180, 0).setDuration(duration).start();//翻转
                ObjectAnimator.ofFloat(view, "rotationY", 0, 180, 0).setDuration(duration).start();
                ObjectAnimator.ofFloat(view, "rotation", 0, 180, 0).setDuration(duration).start();//旋转
             ViewHelper.setPivotX(view, view.getWidth() / 2f);//设置动画基点
             ViewHelper.setPivotY(view, view.getHeight() / 2f);

以上就是比较常用的nineold,但是偶尔遇到组合的,这样就比较省事

AnimatorSet animator = new AnimatorSet();
		animator.playTogether(
		    ObjectAnimator.ofFloat(p_w_picpath, "rotation", 0, 1080),
		    ObjectAnimator.ofFloat(p_w_picpath, "translationX", 0, 180),
		    ObjectAnimator.ofFloat(p_w_picpath, "translationY", 0, -180),
		    ObjectAnimator.ofFloat(p_w_picpath, "scaleX", 1, 0),
		    ObjectAnimator.ofFloat(p_w_picpath, "scaleY", 1, 0)
		    ObjectAnimator.ofFloat(p_w_picpath, "alpha", 1, 0.25f, 1)
		);
		animator.setDuration(5 * 1000).start();

今天做一个添加商品到购物车时 商品图片旋转 缩小 位移 到指定的购物车图标位置,用的属性动画,很麻烦,动画执行顺序如果弄乱了,位移轨迹会出问题的.大概记录一下,以免忘了

		int[] endLocation = new int[2];
		topSpcart.getLocationInWindow(endLocation);// shopCart是那个购物车
		
		// 计算位移
		int endX = endLocation[0] - startLocation[0] ;// 动画位移的X坐标
		int endY = endLocation[1] - startLocation[1];// 动画位移的y坐标
		
		RotateAnimation rotateAnimation = new RotateAnimation(0, 1080,    
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
		ScaleAnimation scaleAnimation =new ScaleAnimation(1, 0, 1, 0,   
				Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);   
		TranslateAnimation translateAnimation = new TranslateAnimation(0,endX, 0, endY);
//		translateAnimation.setInterpolator(new LinearInterpolator());//动画加速器
//		translateAnimation.setInterpolator(new AccelerateInterpolator());
//		translateAnimation.setRepeatCount(0);// 动画重复执行的次数
//		translateAnimation.setFillAfter(true);//动画结束留在原位置
		
		AnimationSet set = new AnimationSet(false);
		set.setFillAfter(true);
		set.addAnimation(rotateAnimation);//旋转
		set.addAnimation(scaleAnimation);//缩放
		set.addAnimation(translateAnimation);//位移
		set.setDuration(1000);// 动画的执行时间
		view.startAnimation(set);
		// 动画监听事件
		set.setAnimationListener(new AnimationListener() {
			// 动画的开始
			@Override
			public void onAnimationStart(Animation animation) {
			}
			@Override
			public void onAnimationRepeat(Animation animation) {
			}
			// 动画的结束
			@Override
			public void onAnimationEnd(Animation animation) {
			}
		});

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章标题:Android属性动画备忘nineold-创新互联
分享URL:http://bjjierui.cn/article/dhpggd.html

其他资讯