android Animation 动画效果收集

1.点击后放大缩小实现

Android的事件:onClick, onScroll, onFling等等,都是由许多个Touch组成的。其中Touch的第一个状态肯定是ACTION_DOWN, 表示按下了屏幕。之后,touch将会有后续事件

对控件进行设置点击事件

findViewById(R.id.layout_click).setOnTouchListener(this);
findViewById(R.id.layout_click).setOnClickListener(this);

@Override
	public boolean onTouch(View v, MotionEvent event) {
		
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:  //
			if(v.getId()==R.id.layout_click){
				Animation animation=new ScaleAnimation(1.0f, 0.9f, 1.0f, 0.9f, 
						Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
				animation.setDuration(100);
				animation.setFillAfter(true);
				v.startAnimation(animation);
			}
			break;
		case MotionEvent.ACTION_UP:  //
			if(v.getId()==R.id.layout_click){
				Animation animation=new ScaleAnimation(0.9f, 1.0f, 0.9f, 1.0f, 
						Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
				animation.setDuration(100);
				animation.setFillAfter(true);
				v.startAnimation(animation);
			}
			break;
		default:
			break;
		}
		return false;
	}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值