Search code examples
androidandroid-animationandroid-gallery

Gallery Selected Position Animation


am trying to use this myGallery.setSelection(5, true); (Gallery.setSelection(Position, Animate);), which 5 is the requested position.

should this method animate the gallery till the new selected position is shown?? or just jumps to the selected position directly?

because when i use it, no animation happens !!


Solution

  • set animation for on item selected listener. The animation will call only for selected gallery item.

    myGallery.setOnItemSelectedListener(new OnItemSelectedListener(){
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
            arg1.setAnimation(AnimationUtils.loadAnimation(this, R.anim.scale_img));
        }
    });
    

    this will help you.