0
我是初学者,当谈到这些事情时,如果这是一个简单的问题,请道歉。ImageSwitcher在动画之前显示图像
我试图实现ImageSwitcher来循环一组图像。要做到这一点,我试图实现这里描述的计时器:How to make an ImageSwitcher switch the image every 5 secs?
我得到的图像循环通过很好,但图像加载,然后发生动画。将显示图像1,然后它将切换到图像2,然后淡出图像2并将其再次淡入。然后图像2将显示指定的时间,并重复该过程。
我想图片1淡出,然后淡入图像2
这是我到目前为止有:。
imageSwitcher = (ImageSwitcher) findViewById(R.id.welcome_image);
imageSwitcher.setFactory(this);
imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
从上述问题的计时器:
Timer t = new Timer();
//Set the schedule function and rate
t.scheduleAtFixedRate(new TimerTask() {
public void run() {
//Called each time when 1000 milliseconds (1 second) (the period parameter)
currentIndex++;
// If index reaches maximum reset it
if(currentIndex==messageCount)
currentIndex=0;
runOnUiThread(new Runnable() {
public void run() {
imageSwitcher.setImageResource(imageIDs[currentIndex]);
}
});
}
},1000,5000);
And
public View makeView() {
ImageView imageView = new ImageView(this);
imageView.setBackgroundColor(0x00000000);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
return imageView;
}
我非常感谢一些帮助。