如何从嵌套的Crollview内部拖动底部表视图?
我的底部表格查看a nestedscrollview ,我想在从nestedscrollview向下滚动时拖动
但这是行不通的。bottomSheet
我的XML代码如下:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:behavior_hideable="true"
app:behavior_peekHeight="230dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/window_background"
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
...
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
...
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I have inside my BottomSheet view a NestedScrollView and I want to drag down the bottomSheet
when scrolling down from the nestedScrollview
but it is not working.
My XML code is like below :
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:behavior_hideable="true"
app:behavior_peekHeight="230dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/window_background"
app:elevation="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
...
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
...
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
启用了
nestedscrollview
的嵌套滚动,它没有拖到BottomSheet
之所以拖动,该滚动已启用,这会捕获滚动事件,直到一路向上滚动为止。禁用
nestedscrollview
不是一个选项,因为它在底部滚动中需要。间歇性启用/禁用可能会导致意外的滚动行为。解决方法:解决此问题的一种选择;每当
nestedScrollview
检测到向上的滚动时,都会一直向上滚动,以便底部表可以折叠的机会:用户将看到
的顶部内容的下侧nestedscrollview
在关闭之前;即使他们改变了不崩溃的主意。可能不是最好的选择;但这很简单并且有效。The reason it's not dragging down the
BottomSheet
that the nested scrolling of theNestedScrollView
is enabled which catches the scrolling event until scrolling all the way up.Disabling the
NestedScrollView
is not an option because it's needed in bottom scrolling. And intermittent enabling/disabling of it can cause unexpected scrolling behavior.Workaround: An option to solve this; is to scroll all the way up whenever the
NestedScrollView
detects an up scroll, so that the bottom sheet can take the chance of collapsing:The down side that the user would see the top content of the
NestedScrollView
before it goes off; or even if they changed their mind of not collapsing the bottom sheet. Probably not the best option; but it is simple and works.