Android TimePicker(轮式)无法正确响应 ScrollView 内的轻拂手势
我有一个包含滚动视图的对话框,其中包含带有两个时间选择器的布局。
时间选择器是 ICS 中较新风格的时间选择器。
问题是,当您通过拖动或轻弹滚轮来更改时间时,它们似乎会争夺焦点。它将稍微改变时间,然后布局将滚动。
有什么想法吗? 提前致谢。
I have a dialog box that contains a Scrollview, which contains a layout with two TimePickers.
The timepickers are the newer style ones, what's in ICS.
The problem is that they seem to fight for focus when you change the time by dragging the wheel, or flicking it. It will change the time just a little, and then the layout will scroll instead.
Any ideas?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在使用 Holo 主题时遇到了同样的问题,在这里我找到了解决方案: https://groups.google.com/forum/?fromgroups#!topic/android-developers/FkSfJI6dH8w
您必须实现自定义 DatePicker 或TimePicker 并重写以下方法:
I had the same problem when using the Holo theme, and here is where I found the solution: https://groups.google.com/forum/?fromgroups#!topic/android-developers/FkSfJI6dH8w
You must implement your custom DatePicker or TimePicker and override the following method:
由于 Klemens Zleptnig 的链接已损坏,因此这里是一个完整的示例。顺便说一句,此修复也有助于 TabLayout 的滚动。我排除了 TimePicker 顶部大数字周围的区域,因为它们无论如何都不需要滚动事件。
xml:
java:
Because the link from Klemens Zleptnig is broken, here is a complete example. This fix helps with the scroll of a TabLayout too btw. I excluded the area around the big numbers in the top of the TimePicker because they don't need the scroll event anyway.
xml:
java: