Android 有没有办法让动画列表xml集drawable突然变成BitmapDrawable?

Android 有没有办法让动画列表xml集drawable突然变成BitmapDrawable?,android,android-animation,bitmapdrawable,Android,Android Animation,Bitmapdrawable,所以我有这个动画列表,它是一系列的图像 <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@drawable/image1" android:duration="2000" />

所以我有这个动画列表,它是一系列的图像

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> 
    <item android:drawable="@drawable/image1" android:duration="2000" /> 
    <item android:drawable="@drawable/image2" android:duration="2000" /> 
</animation-list>
以下是我在AnimationClass中提到的内容:

public void run() {
    ((AnimationDrawable) mImages.getDrawable()).start();
}
mImages变量就是我在xml中的变量。我正在向用户显示它们,就像一个splashImage。问题是我有时会犯这个错误,我不知道它是怎么发生的

附言。
我故意更改了一些变量名和包名,但希望代码仍然像我一样清晰。

每当你将位图设置为
ImageView
以便循环使用时,android将创建新的
BitmapDrawable
对象

BitmapDrawable drawable =new BitmapDrawable(bitmap);
并将其设置为
ImageView
。因为在
ImageView
中循环使用
位图

drawable.getBitmap().recycle();

这就是为什么它会返回
BitmapDrawable
object

,但为什么在使用应用程序时,错误不会总是在随机时间出现?@JohnErnestGuadalupe没有明白你说的话。你能解释清楚吗?OP根本没有提到ImageView,那么为什么要这样做呢?是的,我实际上使用的是一个ImageView,我在其中设置动画列表。我想问的是,为什么我会遇到上面的错误,其中BitmapDrawable无法转换为AnimationDrawable,而实际上它大部分时间都工作正常,然后崩溃,只是有时会显示错误。考虑到你的答案,它不应该更频繁地崩溃吗?@JohnErnestGuadalupe这是一个例外吗??
drawable.getBitmap().recycle();