android 双击点赞动画,模仿android版instagram双击点赞效果

先上效果图

7d1a3ed9725c

效果图.gif

实现双击的效果,然后将点赞的动画体现出来。

1 双击效果

Android sdk给我们提供了GestureDetecto这个类,GestureDetector这个类对外提供了两个接口:OnGestureListener,OnDoubleTapListener,还有一个内部类SimpleOnGestureListener。

public class OnDoubleClick extends GestureDetector.SimpleOnGestureListener {

@Override

public boolean onDoubleTap(MotionEvent e) {

//双击

return false;

}

public boolean onSingleTapConfirmed(MotionEvent e) {

//单击

return false;

}

}

实例化GestureDetector

GestureDetector mGestureDetector = new GestureDetector(this, new OnDoubleClick());

将view的onTouch监听捕捉到

view.setOnTouchListener(new OnTouchListener() {

@Override

public boolean onTouch(View view, MotionEvent event) {

return mGestureDetector.onTouchEvent(event);

}

});

双击操作捕捉到后就开始动画效果,这里用简单的ScaleAnimation

ScaleAnimation animation_ScaleAnimation = new ScaleAnimation(1.0f, 1.5f, 1.0f, 1.5f,

Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

animation_ScaleAnimation.setDuration(600);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值