Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android AnimationDrawable帧持续时间问题_Android - Fatal编程技术网

Android AnimationDrawable帧持续时间问题

Android AnimationDrawable帧持续时间问题,android,Android,我需要逐帧创建动画,但我有一些问题 我有30个png图像组成了我的动画,我用以下代码加载我的AnimationDrawable: mCurrentAnimation = new AnimationDrawable(); mCurrentAnimation.setOneShot(true); int resId; for (int j = 1; j < 31; j++) {

我需要逐帧创建动画,但我有一些问题 我有30个png图像组成了我的动画,我用以下代码加载我的AnimationDrawable:

        mCurrentAnimation = new AnimationDrawable();
        mCurrentAnimation.setOneShot(true);
        int resId;
        for (int j = 1; j < 31; j++)
        {                  
            resId = getResources().getIdentifier("resName", "drawable", "com.mindcolorstest.main");
            mCurrentAnimation.addFrame(getResources().getDrawable(resId), 1);
        }
mCurrentAnimation=newanimationdrawable();
mCurrentAnimation.setOneShot(true);
国际剩余;
对于(int j=1;j<31;j++)
{                  
resId=getResources().getIdentifier(“resName”、“drawable”、“com.mindcolorstest.main”);
addFrame(getResources().getDrawable(resId),1);
}
并从逻辑上“mCurrentAnimation.start()”开始 在mdpi设备上,动画效果很好,但我对每帧的持续时间有一些问题,在hdpi emulator或设备上,我有一些延迟,如果我减少帧的持续时间(在mdpi或hdpi设备上),动画将不会更快,就像存在每帧的最小持续时间一样。 一些提示和技巧?我不知道我要做什么
无论如何,谢谢你

我同意这一点,我对xml动画列表做的或多或少都是一样的,即使在S4上,我每帧的动画时间比我设置的要长得多。(我已将持续时间设置为每帧3ms)
我测量了30个周期和85个帧中每帧的最小平均值
16,16ms

这可能会也可能不会响应行
scheduleSelf(mAnimationRunnable,现在+1000/60)drawablecainer
中的
animate()。只是一个猜测,因为
1000/60=16,66
作为int/long cast应该变成什么
16


但它也可能来自代码或硬件速度的其他限制。
我没有检查此行中的代码是否被调用,是否是导致此问题的原因,因为我无法在那里中断。

然而,我认为现实中没有显示速度那么快,所以看起来很聪明。

为什么在这里使用for循环图像在定义的时间内自行加载…for循环仅用于加载对象AnimationDrawable中的图像。。。mCurrentAnimation.start()将启动图像背景切换并创建结果动画,我猜这是一种错误的方式,在哪个小部件上显示动画…((ImageView)findViewById(R.id.imageAnim)).setBackgroundDrawable(mCurrentAnimation);我希望您的xml for animation文件位于res/anim文件夹中。