与地图片段交互时禁用swiperefreshlayout和scrollview

时间:2017-03-29 14:37:14

标签: android scrollview swiperefreshlayout

我目前有以下布局高级布局

List<string> cells = new List<string>();
cells.Add("$C$4");
cells.Add("$D$5");
cells.Add("$H$10");

for (int idx = 0; idx < cells.Count; idx++)
    cells[idx] = String.Format("'{0}'!{1}", (excelApp.ActiveSheet as _Excel.Worksheet).Name, cells[idx]);
string rangeDef = String.Format("={0}", String.Join(";", cells));

var sheet = (excelApp.ActiveSheet as _Excel.Worksheet).get_Range(rangeDef, Type.Missing).Select();

在我的代码中,我有以下方法

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/swipeRefresh" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <android.support.constraint.ConstraintLayout xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="81dp"> ... <FrameLayout android:id="@+id/location_container" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginEnd="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginStart="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView3" app:layout_constraintVertical_bias="0.0"> <fragment android:id="@+id/fragment_location" android:name="com.nissanshare.vehicleinfo.VehicleLocationFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="8dp" android:tag="fragment_vehicleInfo" tools:layout="@layout/fragment_vehicle_info_location" /> <View android:id="@+id/transparent_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" /> </FrameLayout> ... </android.support.constraint.ConstraintLayout> </ScrollView> </android.support.v4.widget.SwipeRefreshLayout> 是布局中的mTouchInterceptor

transparent_view

这与我在没有使用SwipeRefreshLayout时使用scrollview时使用的代码相同,并且它可以完美地运行。但是,在添加SwipeRefreshLayout时,它似乎并不尊重对private void setupTouchInterceptor() { mTouchInterceptor.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.d(TAG, ".onTouch:DOWN"); // Disallow ScrollView to intercept touch events. mScrollView.requestDisallowInterceptTouchEvent(true); mSwipeRefreshLayout.requestDisallowInterceptTouchEvent(true); return false; case MotionEvent.ACTION_UP: Log.d(TAG, ".onTouch:UP"); // Allow ScrollView to intercept touch events. mScrollView.requestDisallowInterceptTouchEvent(false); mSwipeRefreshLayout.requestDisallowInterceptTouchEvent(false); return true; case MotionEvent.ACTION_MOVE: Log.d(TAG, ".onTouch:MOVE"); mScrollView.requestDisallowInterceptTouchEvent(true); mSwipeRefreshLayout.requestDisallowInterceptTouchEvent(true); return false; default: return true; } } }); } 的调用。如何在与地图交互时阻止SwipeRefreshLayout刷新。

1 个答案:

答案 0 :(得分:0)

只需将ScrollView更改为android.support.v4.widget.NestedScrollView即可。