大佬教程收集整理的这篇文章主要介绍了防止 ItemTouchHelper 在 RecyclerView 中的 Scrollview 中的 TextView 滚动时触发,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想我有一个简单的问题,但由于我是初学者,我不知道如何解决它。我在 recyclervIEw 中有一个简单的列表,还有一个附加到列表项的 itemtouchHelper。 recyclervIEw 在约束布局内的滚动视图中显示一个 TextvIEw。所以一切正常,滚动视图的滚动效果很好,buuut
如果我开始滚动 textvIEw 然后释放我的拇指,同时它的自动滚动(它有一些动力),然后将我的拇指放回视图上,因为我想继续滚动,itemtouchHelper 被触发。这导致行为,即视图正在滚动,同时触发 itemtouchHelper 并等待用户将项目拖到另一个地方。
<androIDx.consTraintlayout.Widget.ConsTraintLayout
androID:ID="@+ID/consTraint_layout_note"
androID:layout_wIDth="match_parent"
androID:layout_height="match_parent"
androID:orIEntation="vertical">
<ScrollVIEw
androID:ID="@+ID/scrollVIEw_note"
androID:layout_wIDth="0dp"
androID:layout_height="0dp"
androID:layout_marginEnd="1dp"
androID:layout_marginBottom="1dp"
app:layout_consTraintBottom_toBottomOf="parent"
app:layout_consTraintEnd_toEndOf="parent"
app:layout_consTraintStart_toStartOf="parent"
app:layout_consTrainttop_totopOf="parent">
<TextVIEw
androID:ID="@+ID/note_String"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
app:layout_consTraintBottom_toBottomOf="parent"
app:layout_consTraintEnd_toEndOf="parent"
app:layout_consTraintStart_toStartOf="parent"
app:layout_consTrainttop_totopOf="parent" />
</ScrollVIEw>
</androIDx.consTraintlayout.Widget.ConsTraintLayout>
所以我基本上想要的是防止 itemtouchHelper 被触发,只要 textvIEw 正在滚动(即使是它自己),而不是只要用户将他的拇指放在 textvIEw 上。我尝试尝试覆盖视图中的 on touch 方法和命令 v?.parent?.requestdisallowIntercepttouchEvent(true) 例如像这样
init {
binding.noteString.setontouchListener { v,event ->
v?.parent?.requestdisallowIntercepttouchEvent(false)
true
}
binding.scrollVIEwNote.setontouchListener(VIEw.ontouchListener { v,event ->
v.parent.requestdisallowIntercepttouchEvent(true)
false
})
binding.consTraintLayoutNote.setontouchListener { v,event ->
v?.parent?.requestdisallowIntercepttouchEvent(false)
false
}
但我所做的只是完全停止滚动。
我自己无法取得任何进展,所以我想请教一下这里的人。有人知道一些帮助吗?如何检测,如果 textvIEw 正在滚动,然后阻止 itemtouchHelper 触发?
提前谢谢。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的防止 ItemTouchHelper 在 RecyclerView 中的 Scrollview 中的 TextView 滚动时触发全部内容,希望文章能够帮你解决防止 ItemTouchHelper 在 RecyclerView 中的 Scrollview 中的 TextView 滚动时触发所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。