侧滑FrameLayout的坑

源码SlidingFrameLayout

Android群英传第五章笔记·Android Scroll分析
ViewDragHelper本质是通过offsetLeftAndRight(offX)和offsetTopAndBottom(offY)来实现移动的

由于项目需要,要做一个类似DrawLayout的一个FrameLayout,可以在屏幕右侧边缘拉出,也可以拉动隐藏。采用了上面链接的解决方法,但是上面的方法有一个坑(当屏幕其他动作,导致自定义的FrameLayout进行layout的时候会回到初始位置)。由于是移动是本身,不是子View,且不改变父布局,因此不能采用scrollto(ps:采用scrollto的也有一种办法,就是获取到ContentView,addView(this))

侧滑FrameLayout的坑_第1张图片
Paste_Image.png

坑的解决办法

侧滑FrameLayout的坑_第2张图片
Paste_Image.png

你可能感兴趣的:(侧滑FrameLayout的坑)