Blackberry - 如何实现ListField平滑滚动?

发布于 2024-07-27 00:10:30 字数 676 浏览 14 评论 0原文

概述
我正在使用 listfield 类来垂直显示一组信息。 该列表字段的每一行占据屏幕高度的 2/5。

因此,当滚动到下一个项目时(特别是当显示因屏幕高度的限制而部分遮挡的项目时),整个滚动/聚焦动作非常跳跃。

我想通过在滚动/焦点操作之间实现平滑滚动来解决这种跳跃问题。 ListField 类可以做到这一点吗?

示例
下面是显示当前问题的屏幕截图。

替代文本
(来源:perkmobile.com

一旦用户向下滚动到 ListFieldTHREE 行,这一行以一种非常跳跃的方式“滚动”到视图中,没有平滑的滚动。 我知道减小行高可以缓解这个问题,但我不想这样做。

主要问题
如何在 ListField 中平滑滚动?

Overview
I'm using a listfield class to display a set of information vertically. Each row of that listfield takes up 2/5th's of the screen height.

As such, when scrolling to the next item (especially when displaying an item partially obscured by the constraints of the screen height), the whole scroll/focus action is very jumpy.

I would like to fix this jumpiness by implementing smooth scrolling between scroll/focus actions. Is this possible with the ListField class?

Example
Below is a screenshot displaying the issue at hand.

alt text
(source: perkmobile.com)

Once the user scrolls down to ListFieldTHREE row, this row is "scrolled" into view in a very jumpy manner, no smooth scrolling. I know making the row height smaller will mitigate this issue, but I don't wan to go that way.

Main Question
How do I do smooth scrolling in a ListField?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏尔 2024-08-03 00:10:30

据我所知,没有官方的 API 方法可以做到这一点,但它可能可以通过巧妙地使用 NullField(Field.FOCUSABLE) 来伪造,这就是许多自定义 BlackBerry UI 实现强制焦点行为的方式。

一种方法是从一个类派生每个“列表项”,该类将可聚焦的 NullFields 与列表项本身的可见内容交错在一起——这实际上会迫使滚动系统以更小的间隔“跳跃”,而不是由列表项之间的自然划分,并且具有不修改列表项内容的可见定位的附带好处。

There isn't an official API way of doing this, as far as I know, but it can probably be fudged through a clever use of NullField(Field.FOCUSABLE), which is how many custom BlackBerry UIs implement forced focus behavior.

One approach would be to derive each "list item" from a class that interlaces focusable NullFields with the visible contents of the list item itself -- this would essentially force the scrolling system to "jump" at smaller intervals rather than the large intervals dictated by the natural divisions between the list items, and would have the side benefit of not modifying the visible positioning of the contents of the list item.

千年*琉璃梦 2024-08-03 00:10:30

假设您希望用户向下滚动轨迹球“单击”1 次,然后突出显示下一个项目,但不是立即滚动跳转,而是平滑滚动以使新项目可见(就像在 Google 的 Gmail 应用程序中一样) BlackBerry),您必须推出自己的组件。

基本思想是子类化 VerticalFieldManager,然后在滚动时(关闭 moveFocus 方法),您有一个单独的线程更新垂直位置变量,并使管理器多次无效。

该线程是必要的,因为如果您考虑一下,您正在从用户事件驱动动画 - 平滑滚动实际上是 BlackBerry 上的动画,因为它比触发它的事件持续时间更长。

我对细节有点模糊,这并不是一件容易的事情,所以希望这对您有所帮助。

Assuming you want the behavior that the user scrolls down 1 'click' of the trackball, and the next item is then highlighted but instead of an immediate scroll jump you get a smooth scroll to make the new item visible (like in Google's Gmail app for BlackBerry), you'll have to roll your own component.

The basic idea is to subclass VerticalFieldManager, then on a scroll (key off the moveFocus method) you have a separate Thread update a vertical position variable, and invalidate the manager multiple times.

The thread is necessary because if you think about it you're driving an animation off of a user event - the smooth scroll is really an animation on the BlackBerry, as it lasts longer than the event that triggered it.

I've been a bit vague on details, and this isn't a really easy thing to do, so hopefully this helps a bit.

忆离笙 2024-08-03 00:10:30

除非您想覆盖列表字段的绘制方式或创建自己的包装器,否则您将始终遇到此问题,这是因为滚动时每行始终可见。 尝试使用 labelfield 代替。

unless you want to override the how the listfield paints or create your own wrapper, you will always have this issue, this is because each line is always visible when scrolling. Try using labelfield instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文