[英]SwipeRefreshLayout gesture detection in drawer
I'm using SwipeRefreshLayout in drawer. 我在抽屉里使用SwipeRefreshLayout。 When I stat scrolling up and down in the listview the gesture should be straight up and down, If the finger moves just a little bit a side without lifting it up, the scroll gesture stops and starts the gesture for open close the drawer.
当我在列表视图中向上和向下滚动时,手势应该是直线上下移动,如果手指只是移动一点而不抬起它,滚动手势就会停止并启动手势以打开关闭抽屉。 If I'm not using SwipeRefreshLayout, the scroll gesture dose not stops until I lift my finger up.
如果我没有使用SwipeRefreshLayout,滚动手势不会停止,直到我举起手指。
This is the layout: 这是布局:
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_to_refresh_lisview_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
tools:ignore="NestedWeights" >
<views.IndexableListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" />
</android.support.v4.widget.SwipeRefreshLayout>
The code is the same as this one: http://antonioleiva.com/swiperefreshlayout/ 代码与此相同: http : //antonioleiva.com/swiperefreshlayout/
I had the same problem. 我有同样的问题。 You have to "lock" the drawer while you are scrolling and unlock it again when the scrolling even finish.
滚动时必须“锁定”抽屉,滚动均匀后再次解锁。 For that I used 2 things:
为此,我使用了两件事:
add an OnScrollListener to your listView like: 将OnScrollListener添加到listView,如:
mDrawerListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { if (i == SCROLL_STATE_IDLE) mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); else mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN); } @Override public void onScroll(AbsListView absListView, int i, int i2, int i3) { } });
To avoid some problems trying to fire "refresh event", you should implement the work around suggested by spencer on this link: Issue 69074 为避免尝试触发“刷新事件”时出现问题,您应该在此链接上实现spencer建议的解决方法: 问题69074
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.