Questions tagged «gesture»


8
SwipeRefreshLayout + ViewPager,仅限制水平滚动吗?
我已经实现了,SwipeRefreshLayout并且ViewPager在我的应用程序中,但是有一个大麻烦:每当我要左右滑动以在页面之间切换时,滚动就太敏感了。稍微向下滑动也会触发SwipeRefreshLayout刷新。 我想为开始水平滑动设置一个限制,然后仅在滑动结束之前强制水平滑动。换句话说,当手指水平移动时,我想取消垂直滑动。 仅当发生以下问题时ViewPager,如果我向下滑动并SwipeRefreshLayout触发刷新功能(显示条),然后水平移动手指,则仍然只能垂直滑动。 我试图扩展ViewPager该类,但它根本不起作用: public class CustomViewPager extends ViewPager { public CustomViewPager(Context ctx, AttributeSet attrs) { super(ctx, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { boolean in = super.onInterceptTouchEvent(ev); if (in) { getParent().requestDisallowInterceptTouchEvent(true); this.requestDisallowInterceptTouchEvent(true); } return false; } } 布局xml: <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/viewTopic" android:layout_width="match_parent" android:layout_height="match_parent"> <com.myapp.listloader.foundation.CustomViewPager android:id="@+id/topicViewPager" android:layout_width="match_parent" android:layout_height="match_parent"/> </android.support.v4.widget.SwipeRefreshLayout> 任何帮助,将不胜感激,谢谢
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.