DrawerLayout ListVIEw
当我向上/向下滑动时,列表会滚动.当我向左滚动时,抽屉关闭:完美.当我开始向下滑动然后改变方向时,初始方向(水平/垂直)被锁定.
但是,如果我将列表包装在SwipeRefreshLayout中,如下所示:
DrawerLayout SwipeRefreshLayout ListVIEw
..然后锁定滚动/滑动方向不再起作用.当我向上/向下滑动然后向左/向右滑动一下时,列表会滚动并且抽屉也会移动.后者不是我想要的.
有关如何使用SwipeRefreshLayout恢复前一行为的任何建议?
解决方法 我有同样的问题,但使用RecyclerVIEw而不是ListVIEw.最简单的解决方法是扩展SwipeRefreshLayout,当检测到向下滚动时,告诉父(抽屉)布局不要拦截事件(例如滑动抽屉).import androID.content.Context;import androID.support.v4.Widget.SwipeRefreshLayout;import androID.util.AttributeSet;import androID.vIEw.MotionEvent;import androID.vIEw.VIEwConfiguration;public class DrawerSwipeRefreshLayout extends SwipeRefreshLayout { private int touchSlop; private float initialDownY; public DrawerSwipeRefreshLayout(Context context,AttributeSet attrs) { super(context,attrs); touchSlop = VIEwConfiguration.get(context).getScaledtouchSlop(); } @OverrIDe public boolean onIntercepttouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: initialDownY = event.getY(); break; case MotionEvent.ACTION_MOVE: final float eventY = event.getY(); float yDiff = Math.abs(eventY - initialDownY); if (yDiff > touchSlop) { getParent().requestdisallowIntercepttouchEvent(true); } } return super.onIntercepttouchEvent(event); }}总结
以上是内存溢出为你收集整理的android – 抽屉里面的SwipeRefreshLayout里面的ListView(布局):不锁定滚动方向全部内容,希望文章能够帮你解决android – 抽屉里面的SwipeRefreshLayout里面的ListView(布局):不锁定滚动方向所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)