您的位置:首页 > 移动开发 > Android开发

android Animation 动画效果收集

2016-02-19 17:41 369 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息