2

Essentially what I want to happen is, after the user scrolls the list, I want the elements to snap into 'grids' instead of remaining where they are, so that I can center the middle component in the list, like in the picture.

enter image description here

I tried manually changing the setSelectedIndex after setting ScrollToSelected to true, but that lacks any animation, and the list scrolls the element to the edge of the screen, rather than the middle.

How can I have the effect of scrolling the element with animation, and to the middle of the screen?

Pat
  • 1,193
  • 1
  • 11
  • 36
  • did you try it with the .getScrollX() or .setScrollX(int i) mehtods. I guess this is what you might be needing. Let me know about it. – Nitesh Verma Oct 31 '13 at 10:35

1 Answers1

1

LWUIT & Codename One both have a snap to grid property in Container and in List. Did you activate it? Just use setSnapToGrid(true) on any component.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I've tried it on the list. But it doesn't center the items properly. There's still a gap on the left and the item on the right is. Though I suspect it's from my components. I ended up implementing my own list since I also needed to control the speed of the scroll and how many items are scrolled with every drag. – Pat Nov 04 '13 at 07:27
  • I suggest you migrate to Codename One which is better supported, implementing your own list is a path of deep complexity. – Shai Almog Nov 04 '13 at 16:09
  • It's a simple list. I know there will be 20 items max, so I just did a container and override the pointer pressed/released and did the scrolling manually. They require us to use the LWUIT library at work, so I can't use Codename One. – Pat Nov 04 '13 at 16:20