yuqirong / CardSwipeLayout

Use RecyclerView to achieve card swipe layout , like Tantan . (模仿探探卡片滑动效果的布局)
MIT License
1.25k stars 187 forks source link

如果下面有两个按钮,点击喜欢不喜欢实现左划右划的效果怎么处理,求解惑 #4

Closed GuilinSir closed 7 years ago

hushiguang commented 7 years ago

你可以自己写个ValueAnimation然后模拟滑动数据,调用onChildDraw方法,可以实现,我是这么做的

specloli commented 7 years ago

求源码分享,现在正在做一个类似的,但是是敏捷开发,正在拼命加班中...

hushiguang commented 7 years ago

这是动画部分 ` / 点击的动画 / private void valueAnimation(final boolean isLeft) { ValueAnimator animator = ValueAnimator.ofFloat(0, isLeft ? -ScreenUtil.getDisplayWidth() : ScreenUtil.getDisplayWidth()); animator.setInterpolator(new LinearInterpolator()); animator.setDuration(200); final RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(mRecyclerView.getChildAt( mRecyclerView.getChildCount() > CardConfig.DEFAULT_SHOW_ITEM ? 0 + CardConfig.DEFAULT_SHOW_ITEM : mRecyclerView.getChildCount() - 1)); mFloatLeftButton.setEnabled(false); mFloatRightButton.setEnabled(false); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); cardCallback.onChildDraw(cardCallback.getCanvas(), mRecyclerView, holder, value, 0, ItemTouchHelper.ACTION_STATE_SWIPE , true); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); cardCallback.onSwiped(holder, isLeft ? ItemTouchHelper.LEFT : ItemTouchHelper.RIGHT); cardCallback.clearView(mRecyclerView, holder); } }); animator.start();

}`

然后在Callback里面你需要把Canvas拿出来 然后就看你们需求是什么了

hushiguang commented 7 years ago

@specloli 你挑有用部分去用

specloli commented 7 years ago

@hushiguang 感谢!!!

yuqirong commented 7 years ago

现在将此 issue 关闭 , 有问题可以参考 @hushiguang 上面的代码。

LoveqLRC commented 7 years ago

表示没看明白,希望作者能加上去,@hushiguang getCanvas() 和onChildDraw里面的实现是什么?

yuqirong commented 7 years ago

@LoveqLRC 具体可以看 dev 分支 里面根据这个思想写了一个按钮点击滑动卡片的

LoveqLRC commented 7 years ago

@yuqirong 感谢你的无私奉献

ThugKd commented 6 years ago

撤回功能有吗

xuxinyuancode commented 6 years ago

@specloli 老哥,请问你解决了点击滑动这个问题了吗?

ThugKd commented 6 years ago

@204663476 dev分支有源码啊

xuxinyuancode commented 6 years ago

@ThugKd 看到了,谢谢

xuxinyuancode commented 6 years ago

@yuqirong @ThugKd item内如果有scrollview会出现滑动冲突,有什么解决办法吗?

longkehuawei commented 5 years ago

@ThugKd 分支在哪里呀,找不到

longkehuawei commented 5 years ago

@xuxinyuancode 分支在哪里?