android - 滚动ScrollView android上的显示和隐藏按钮
问题描述
我有一个nested scrollview
和一个button
。我想在滚动时隐藏按钮,并在滚动停止时scrollview
显示,无论向上滚动和向下滚动。button
有人请帮忙。
解决方案
最后我找到了解决方案。
scrollView.setOnTouchListener(object : View.OnTouchListener {
override fun onTouch(p0: View?, p1: MotionEvent?): Boolean {
when (p1!!.getAction()) {
MotionEvent.ACTION_SCROLL, MotionEvent.ACTION_MOVE -> {
closeCaseButton.visibility = View.INVISIBLE
}
MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> {
closeCaseButton.visibility = View.VISIBLE
}
}
return false
}
})
推荐阅读
- ios - 如何使用 swiftUI 更改键盘以反映段选择的输入类型?
- microsoft-graph-api - 图形订阅测试版 - AdditionalData
- python-3.x - 为pygame项目随机化背景音乐
- flutter - 在颤振应用程序中获取浮动操作按钮错误
- angular - 为什么没有调用函数?(在 Ionic & Angular 框架中)
- reactjs - 如何将数字作为道具传递给样式化组件?
- laravel - Laravel 助手
- java - 为什么这个 JAVA 端点没有向客户端返回详细的错误消息?
- python - 如何从先前分配的索引中获取值
- reactjs - 从 Blazor 服务器调用 React App.Render