好吧。很长一段时间过去了,你可能已经解决了这个问题,但是你得到了AnimationDrawable的setEnterFaceDuration()。例如:
mBackgroundAnimation = new AnimationDrawable();
mBackgroundAnimation.addFrame(getResources().getDrawable(R.drawable.background1), 5000);
// ... rest of the frames
mBackgroundAnimation.addFrame(getResources().getDrawable(R.drawable.background6), 5000);
mBackgroundAnimation.setEnterFadeDuration(1000);
mBackgroundAnimation.setOneShot(false);
有了这个代码你必须通过1..N图像的容易循环,每一个保持5秒(5000毫秒)与淡入动画。现在,我做的是设置我的根的背景RelativeLayout的
mLayoutRoot.setBackground(mBackgroundAnimation);
mLayoutRoot.post(new AnimationStarterThread());
而且AnimationStarterThread类
private class AnimationStarterThread implements Runnable {
public void run() {
if(mBackgroundAnimation != null)
mBackgroundAnimation.start();
}
}
嗯,我甚至不记得我做过什么:-)但你的解决方案看起来非常干净,所以让我们将其标记为答案! – Redwarp 2012-07-23 12:41:06
有没有办法让它只有一个循环? – Andy 2012-09-20 21:09:51
目前无法限制循环次数。虽然可以添加,但我认为(从内存中)可以使用原始的TransitionDrawable类来实现。 – 2012-09-23 14:08:52