使用ViewDragHelper进行侧滑功能实现:
View的拖动效果-ViewDragHelper
1.重写onLayout()方法,先进行摆放布局。
View的拖动效果-ViewDragHelper
2.创建ViewDraghelper对象,并且设置能够边缘拖动
View的拖动效果-ViewDragHelper

3.重写ViewDragHelper.Callback
View的拖动效果-ViewDragHelper
View的拖动效果-ViewDragHelper

4.要重写computeScroll()方法,因为在ViewDragHelper中使用Scroller。比如调用settleCapturedViewAt()方法的时候,里层的源码就使用了Scroller
View的拖动效果-ViewDragHelper
5.控制移动的代码
mViewDragHelper.settleCapturedViewAt(-(releasedChild.getMeasuredWidth() + lp2.rightMargin), releasedChild.getTop());

mViewDragHelper.smoothSlideViewTo(mMenuView, -(mMenuView.getMeasuredWidth() + lp2.rightMargin), mMenuView.getTop());
但是都需要调用刷新才可以完成
invalidate();

源码:
https://github.com/yunzheyue/slideView

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-12-31
  • 2021-09-03
  • 2022-12-23
猜你喜欢
  • 2021-08-22
  • 2022-12-23
  • 2021-07-04
  • 2022-01-01
  • 2021-09-21
  • 2021-10-18
  • 2022-02-15
相关资源
相似解决方案