У меня есть 2 фрагмента внутри NestedScrollView
, и один фрагмент содержит RecyclerView
, а другой фрагмент содержит GoogleMap
, и каждый фрагмент содержит текстовое представление в качестве заголовка поверх него.
Когда я долго нажимаю на вид рециркулятора, я показываю вид рециркулятора в полноэкранном режиме, меняя его высоту на 100%.
Теперь я хочу прекратить прокрутку названия фрагмента RecyclerView, но этовсе еще прокручивает заголовок, когда вид переработчика достиг последнего элемента.
Это макет:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<com.myapp.common.CustomNestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true" />
</com.myapp.common.CustomNestedScrollView>
</LinearLayout>
Это выглядит так:

Я попытался остановить прокрутку, расширив CustomNestedScrollView с помощью NestedScrollView, например:
class CustomNestedScrollView : NestedScrollView {
var isEnableScrolling = true
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
constructor(context: Context) : super(context) {}
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
return if (isEnableScrolling) {
super.onInterceptTouchEvent(ev)
} else {
false
}
}
override fun onTouchEvent(ev: MotionEvent): Boolean {
return if (isEnableScrolling) {
super.onTouchEvent(ev)
} else {
false
}
}
}
И установив значение из действия, когда высота равна 100%, например:
nestedScrollView.isEnableScrolling = !isFull
Также попытался остановить прокрутку NestedScrollView, как:
if (isFull) {
nestedScrollView.stopNestedScroll(ViewCompat.TYPE_NON_TOUCH)
} else {
nestedScrollView.startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL, ViewCompat.TYPE_TOUCH)
}
Ожидаемый: 