我的应用程序目前由一个ViewPager
有几个Fragments
. 在特定的情况下,Fragment
我有一个SwipeRefreshLayout
带有一个ScrollView
并进入这个容器的 HorizotalListView 类型TwoWayView
。
问题是当我在未禁用ListView
的垂直滚动中水平滑动时,有时它会在操作过程中破坏水平滑动。SwipeRefreshLayout
这是我试图解决的问题:
horizListView.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
mSwipeRefreshLayout.requestDisallowInterceptTouchEvent(true);
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
mSwipeRefreshLayout.requestDisallowInterceptTouchEvent(false);
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle HorizontalScrollView touch events.
v.onTouchEvent(event);
return true;
}
});
这是我的布局:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_info1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textStyle="bold"
android:textSize="@dimen/text_medium"
android:textColor="@color/light_gray"
android:text="@string/place_proposal" />
<org.lucasr.twowayview.TwoWayView
android:orientation="horizontal"
android:id="@+id/horizlistview"
android:layout_height="230dp"
android:scaleType="centerCrop"
android:drawSelectorOnTop="false"
android:layout_width="fill_parent" />
<TextView
android:id="@+id/tv_info2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/light_gray"
android:textSize="@dimen/text_medium"
android:textStyle="bold"
android:padding="10dp"
android:text="@string/actual_position"
android:paddingTop="5dp" />
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vf"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/include_w"
layout="@layout/include_wicard_homescreen" />
<include
android:id="@+id/include_no_w"
layout="@layout/include_no_wicard" />
</ViewFlipper>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
如果有人可以帮助我,那就太好了。