Я взял класс CustomStreetViewPanoramaView
, который расширяет класс StreetViewPanoramaView
, затем requestDisallowInterceptTouchEvent устанавливается в true, а requestDisallowInterceptTouchEvent - в false.
class CustomStreetViewPanoramaView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : StreetViewPanoramaView(context, attrs, defStyleAttr) {
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
parent.parent.requestDisallowInterceptTouchEvent(true)
}
MotionEvent.ACTION_UP -> {
parent.parent.requestDisallowInterceptTouchEvent(false)
}
}
return super.onInterceptTouchEvent(event)
}
}
Затем в XML вместо использования com.google.android.gms.maps.StreetViewPanoramaView
замените его своим собственным классом с пакетом (com.yourpackage.name.CustomStreetViewPanoramaView
), например:
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
// fragment 1 related view
<ImageView
android:id="@+id/imgView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
// fragment 2 related view
<com.yourpackage.name.CustomStreetViewPanoramaView
android:id="@+id/streetViewPanorama"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/streetView" />
</androidx.core.widget.NestedScrollView>
Сейчас работает как положено. Пусть это кому-нибудь пригодится.