J'ai actuellement la mise en page suivante haute mise en page de niveauDésactiver swiperefreshlayout et scrollview lors de l'interaction avec un fragment de carte
<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>
Et dans mon code, j'ai la méthode suivante
mTouchInterceptor
est le transparent_view
dans la mise en page
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;
}
}
});
}
Ceci est le même code que j'utilise en utilisant simplement scrollview sans SwipeRefreshLayout et ça marche sournois. Toutefois, lors de l'ajout de SwipeRefreshLayout, il semble qu'il ne respecte pas l'appel à requestDisallowInterceptTouchEvent
. Comment empêcher l'actualisation de SwipeRefreshLayout lors de l'interaction avec la carte.