1

I would like move to a specific position in a gallery with animation. For example, I have 100 elements in a gallery and the actual position is 0. I would like to move slowly (animated) to position 99.

I tried the following command, which seemed promising. But it does not animate :-(

gallery.setSelection(int position, boolean animate)

Any hints?

WGS
  • 13,969
  • 4
  • 48
  • 51
mcfly soft
  • 11,289
  • 26
  • 98
  • 202

1 Answers1

0

Maybe you have to use something like this: create animate.xml file

<set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareInterpolator="true">
<translate 
    android:fromXDelta="0%p" android:toXDelta="50%p" // change this to decide the range
    android:duration="500" android:startOffset="0"/>
<translate 
    android:fromXDelta="0%p" android:toXDelta="100%p" 
    android:duration="500" android:startOffset="500"/>

and in your code use this:

Animation inFromRight =  AnimationUtils.loadAnimation(this, R.anim.animate);
gallery.startAnimation(inFromRight);
gallery.setSelection(PicPosition);  

The idea is from this link:

Android gallery slideshow animation

Community
  • 1
  • 1
HK.avdalyan
  • 724
  • 1
  • 6
  • 21
  • Thanks. Can I do this programmatically ? ( without a static xml definition ) 0-99 was only an example. I would like to jump dynamically to any position. 5-60 , 90-10 etc... – mcfly soft Feb 18 '14 at 14:20