2017-08-02 121 views
0

我只是试图插入一帧通过使用图像创建帧动画现在在webp格式下运行良好与下面给出的代码片段上的Android 7.1 Oneplus3但在Android 4.1.1失败(模拟器)与ResourcesNotFoundException说,它无法找到名称为animation.xml的可绘制文件夹中的xml文件。我只是在我的项目中有一个可绘制的文件夹我还添加了vectorDrawables.useSupportLibrary = true作为stackoverflow线程建议之一,我清理了项目并尝试了android:largeHeap =“true”,尽管图像尺寸太小但错误仍然存​​在4.1.1 android API。

imageView = (ImageView) findViewById(R.id.animx); 

imageView.setBackgroundResource(R.drawable.animation); // error happening here 
AnimationDrawable anim = (AnimationDrawable) imageView.getBackground(); 
anim.start(); 

提拉/ animation.xml文件看起来像这样:

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false"> 
    <item android:drawable="@drawable/spinners1" android:duration="70" /> 
    <item android:drawable="@drawable/spinners2" android:duration="70" /> 
    <item android:drawable="@drawable/spinners3" android:duration="70" /> 
    <item android:drawable="@drawable/spinners4" android:duration="70" /> 
</animation-list> 

什么是崩溃的原因是什么?为什么只发生在Android 4.1.1?如果我使用vectorDrawables.useSupportLibrary = true作为自Gingerbread以来支持的设备,那么对于较低的Android版本也会有任何兼容性问题? 这将是显而易见的添加,但文件包括图像和XML存在于项目文件。

回答

0

实际上,为了减少应用程序大小,我用各自的webp格式替换了所有图像,但上面的代码动画给了某些设备上的ResourceNotFoundException。尝试完所有事情后,我从webp切换回png,现在动画在所有设备上都没有问题。所以我认为webp格式对于框架动画并不可靠。这是我的观察。如果你有任何补充,请让我知道。