I'm trying to implement scroll animation for gallery programmatically.
Tried with setSelection(int pos, Boolean animate)
and it's not working.
Is there anyway to override setSelection()
method.
I'm trying to implement scroll animation for gallery programmatically.
Tried with setSelection(int pos, Boolean animate)
and it's not working.
Is there anyway to override setSelection()
method.
I was looking through the Gallery source to see if I could get this feature. It looks like something is possible with this code. However I gave up before I could get it working. It seems like I wasn't passing in the correct coordinates so res always returned false. Would return true if it worked.
Just posting this here in-case someone else wants to give a go at fixing it! (Please post your solution if you manage it!)
Just now I have got this problem. I was need to move just one element of the gallery, so the best solution to me was to emulate key down event
or
Based on Kurru's excellent thinking of simulating clicking next or previous view.
Gallery.setSelection(int position, boolean animate);
Refer below URL: http://groups.google.com/group/android-developers/browse_thread/thread/9140fd6af3061cdf/7f89e53ae53e455b?lnk=gst&q=setselection#7f89e53ae53e455b
Soln: If you're still looking, I have two possible solutions for you, both slightly unpleasant:
(1) You can make the gallery do a fling with a chosen velocity, thus:
myGallery.onFling(null, null, velocity, 0);
By tweaking the velocity, you can set up values to move the selection by one or two in either direction. As the Gallery self-centers, you do not need to get the destination exactly right.
(2) As the Gallery source is available, you can modify it in order to implement your own Gallery. It doesn't look as though you need to add much code to be able to control a fling so as to end at your chosen selection.
I thought I was going to have to do (2), but found I could get away with (1) for my problem.
I made little change in code given by "Kurru". this is working now