Pinki
Pinki

Reputation: 21929

Display gallery elements as a circle

Hi I am using the gallery for displaying images. But the gallery has an end. I don't want this behaviour; I want to repeat the images again and again on both sides of the gallery. Is there a way to display the gallery elements as a circle?

Upvotes: 0

Views: 1430

Answers (1)

Evgeni Shafran
Evgeni Shafran

Reputation: 146

I wrote a tutorial on how to create circular gallery. Read it in my Blog Post here: http://evgeni-shafran.blogspot.com/2011/08/tutorial-custom-gallery-circular-and.html

Here is what i did:

In the adapter i used, i made him think he have a really big element count. and then each element position= position%element.lenght and then i made the first position in the middle.

so what happen is this: (lets do it for 3 elements, you can have what ever amount you like later) This is how the adapter see the elements:

1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3

now you tell him that the first element is in the middle:

1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,->1<-,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3

if you make it a really big number, the user can scroll a lot before getting to the end.

Hope it helped you.

Upvotes: 4

Related Questions