android Animation 动画效果收集

来源:互联网 发布:北京赛车计划软件 编辑:程序博客网 时间:2024/05/22 13:20

1.点击后放大缩小实现

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

对控件进行设置点击事件

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

@Overridepublic 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;}


0 0