我有一个图像加载为背景,当触摸屏幕时,我想用frameanimation为屏幕的那一部分设置动画。我的frameanimation由9个不同的png文件组成,这些文件仅从我想要动画的屏幕部分制作而成。当我使用整个背景作为动画帧时,我可以使用它,但是当我使用setbounds()来告诉frameanimation在哪里绘制时,我最终将frameanimation放大以填充整个屏幕,这也会擦除我的背景。我如何获得保持原始大小的框架并同时找到它?我可以张贴代码后,如果这是不明确的,我不是在COMP现在如何在android中定位FrameAnimation?
public boolean onTouchEvent (MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
this.setBackgroundResource (R.drawable.nova);
Object bg = this.getBackground
touchAni.setBounds (152, 156, 152+140, 156+140);
touchAni = (AnimationDrawable) bg;
if (!touchAni.isRunning())
touchAni.start();
else
{
touchAni.stop();
touchAni.start();
}
}
}
不确定你的意思。我已将代码添加到我的原始问题中。正在发生的事情是,第一次触摸屏幕时,R.drawable.nova animation-list(描述动画的xml文件)被缩放以适应整个屏幕,然后播放动画。随后在屏幕上的触摸在正确的位置绘制新星动画,但是背景不是我想要的(被放大的nova动画覆盖)。我将在哪里准确地添加图像组件?在animation-list xml文件中,还是在onTouchEvent()方法中的某处? – wufoo 2011-01-11 21:40:32