android imageview按钮按下动画效果
2015-11-09 10:05
543 查看
private ImageView today_eat;
today_eat = (ImageView) view.findViewById(R.id.today_eat);
today_eat.setOnClickListener(b);
today_eat.setOnTouchListener(b);
onTouch里面写动画事件
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.today_eat) {
if (event.getAction() == MotionEvent.ACTION_UP) {
ObjectAnimator oa = ObjectAnimator.ofFloat(today_eat,
"scaleX", 0.93f, 1f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(today_eat,
"scaleY", 0.93f, 1f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
ObjectAnimator oa = ObjectAnimator.ofFloat(today_eat,
"scaleX", 1f, 0.93f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(today_eat,
"scaleY", 1f, 0.93f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
} else if (v.getId() == R.id.tomorrow_eat) {
if (event.getAction() == MotionEvent.ACTION_UP) {
ObjectAnimator oa = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleX", 0.93f, 1f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleY", 0.93f, 1f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
ObjectAnimator oa = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleX", 1f, 0.93f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleY", 1f, 0.93f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
}
return false;
}
}
阿里巴巴图库
today_eat = (ImageView) view.findViewById(R.id.today_eat);
today_eat.setOnClickListener(b);
today_eat.setOnTouchListener(b);
onTouch里面写动画事件
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.today_eat) {
if (event.getAction() == MotionEvent.ACTION_UP) {
ObjectAnimator oa = ObjectAnimator.ofFloat(today_eat,
"scaleX", 0.93f, 1f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(today_eat,
"scaleY", 0.93f, 1f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
ObjectAnimator oa = ObjectAnimator.ofFloat(today_eat,
"scaleX", 1f, 0.93f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(today_eat,
"scaleY", 1f, 0.93f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
} else if (v.getId() == R.id.tomorrow_eat) {
if (event.getAction() == MotionEvent.ACTION_UP) {
ObjectAnimator oa = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleX", 0.93f, 1f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleY", 0.93f, 1f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
ObjectAnimator oa = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleX", 1f, 0.93f);
oa.setDuration(500);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(tomorrow_eat,
"scaleY", 1f, 0.93f);
oa2.setDuration(700);
oa.start();
oa2.start();
}
}
return false;
}
}
阿里巴巴图库
相关文章推荐
- 《IT蓝豹》吹雪花demo,学习android传感器
- Android开发中用到的缓存处理
- Android开发使用的常见第三方框架汇总
- 策略模式和工厂模式的区别
- Android图片加载神器之Fresco-圆形圆角二合一[Java代码实现圆形圆角效果]
- Android四大组件之Activity
- Android下拉刷新完全解析,教你如何一分钟实现下拉刷新功能
- Android图片加载神器之Fresco-圆形圆角二合一[Java代码实现圆形圆角效果]
- RxAndroid
- Android开发之自定义控件(二)---onLayout详解
- android菜单动画
- Android自动朗读(TTS)
- Android布局优化
- Android学习路线指南
- Android自定义Animation动画
- Android studio教程:[4]真机测试
- Android 系统语言设置
- Android中View的绘制过程
- android studio 新建工程时提示资源文件出错
- Android之倒计时实现