Scrollable list of dynamic size with snap function

Hi.

I am new to Microej. I would like to try out a use case in which I want to have a scrollable horizontal list of items. In which the centered item should snap into position. The size of each item is dynamic. And the “snapped” item will also add an extra string to the item which is only shown when not moving the list.

Could someone guide me in which direction I should go, trying to implement this?
Regards

Hi @andreaslundeen,

You can have a look at our widget demo: https://github.com/MicroEJ/Demo-Widget (this example is for MicroEJ 4.1.5, if you are using MicroEJ 5, let me know and I will send you this project updated).

This example describes an example of an horizontal carousel (see com.microej.demo.widget.page.CarouselPage).
If you want to add the extra string when the item is snapped, you can modify the render function in ej.widget.carousel.CarouselEntry:

  • When stopped is true the carousel is snapped
  • When selected is true, the item is the center item

So if you want to draw a new string when an element is snapped, you can check if stopped and selected are true.

Regards,

Pierre