John Thomas
John Thomas

Reputation: 4135

How to do an infinite horizontal sliding scroll of images on Android using Delphi XE 5?

We want to show in an Android app a list of images in the similar manner with many gallery apps: horizontal sliding by using a gesture to show the next/previous image.

Also the image viewer should support zoom/pinch (besides other features).

Images can came from a database or from a directory and can be as much as 200-300.

The question is: Which is the best way to implement the slide-show part from the environment described above?

Through animations of a two TImage? There exist a specialized component for this? By using Horizontal Scroll box?

Upvotes: 0

Views: 2675

Answers (2)

FMXExpress
FMXExpress

Reputation: 1276

Stick 10 TRectangle objects in a THorzScrollBox. It could be more or less than 10 depending on the memory that the device has. Align them all to alTop. Load the images for display in TRectangle.Fill.Bitmap.Bitmap.

When the user scrolls down and is near the bottom of the ten, move the top rectangle to the bottom of the chain and load the newest image from your list into the new bottom one.

When the user scrolls up and is near the top of the ten, move the bottom rectangle to the top of the chain and load the newest image from your list into the new top one.

The reason behind doing it this way is that TRectangle is a really light image display container and you are recycling the TRectangle objects instead of deleting and creating them all the time.

It is possible that you will experience a display pop when you move the next TRectangle object to the top of the chain or when you move it to the bottom of the chain. You will have to create code to take care of this either by setting the position on THorzScrollBox or decreasing and increasing the height of the TRectangle as it leaves or enters the view until it is full size.

Upvotes: 3

SilverWarior
SilverWarior

Reputation: 8386

If you have installed samples with your Delphi instalation then you can find several examples of how to do this in:

Samples\FireMonkey\Fireflow

Samples\FireMonkey\MetropolisUIFlipViewDemo

Maybe there are even more of them. I haven't checked every sample so far.

Upvotes: 2

Related Questions