Android自动圆形图库

时间:2010-06-25 05:10:45

标签: android android-animation android-gallery

我正在使用图库小部件包含1-10个要滑动的图像。我知道当我对屏幕进行条纹处理时,图像会从左向右滚动。我希望自动循环画廊10后自动启动第一张图像,是否有自动循环适配器或方式???

         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);

但我只看到第一张图片是动画的..

看一下我的Video ...

2 个答案:

答案 0 :(得分:8)

为Gallery编写一个SpinnerAdapter,它在getCount()方法中返回Integer.MAX_VALUE。然后,在getDropDownView()和getView()中返回View时,将实际项目数的模数应用于position参数。

答案 1 :(得分:1)

我实施了一个最简单的解决方案。 只需returns Integer.MAX_VALUE in it's getCount() method 这将使右侧无限池。 使其成为双面的 pass Integer.MAX_VALUE/2 in the position of child in setSelection(position, animate) 凉。

相关问题