Android Automatic Circular Gallery

2019-03-16 20:28发布

I am having gallery widget contains 1-10 images to slide. I know that when I stripe the screen , the images scroll from left to right. I want automatic circular gallery after 10 automatically start by first image, is there any automatic circular adapter or way ???

         final Gallery g = (Gallery) findViewById(R.id.gallery);
         g.setAdapter(new ImageAdapter(this));
         Animation animation = AnimationUtils.loadAnimation(this,
        R.anim.rotate_indefinitely);

        animation.getInterpolator();
        animation.setDuration(1000);
        animation.setStartOffset(200);
        animation.setRepeatMode(2);
        animation.setFillAfter(false);
        animation.setFillEnabled(true);

        g.setAnimation(animation);
        g.startAnimation(animation);

but I only see the first image is animated ..

Take a look at my Video ...

2条回答
三岁会撩人
2楼-- · 2019-03-16 21:13

I implemented a simplest solution. Just returns Integer.MAX_VALUE in it's getCount() method This will make infinite pool at right side. To make it both sided pass Integer.MAX_VALUE/2 in the position of child in setSelection(position, animate) Cool.

查看更多
叼着烟拽天下
3楼-- · 2019-03-16 21:17

Write a SpinnerAdapter for the Gallery that returns Integer.MAX_VALUE in it's getCount() method. Then, when returning a View in getDropDownView() and getView(), apply modulo of the actual items count to the position argument.

查看更多
登录 后发表回答