我正在关注Google提供的如何将DynamicDrawable与ImageView一起使用的示例.您可以在此处找到它:http://developer.android.com/guide/topics/graphics/drawable-animation.html
imageView.setBackgroundResource(R.drawable.animation);
AnimationDrawable animation = (AnimationDrawable)imageView.getBackground();
animation.start();
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到错误:
java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.AnimationDrawable
Run Code Online (Sandbox Code Playgroud)
Google似乎认为这应该可行,但是如果你不能将BitmapDrawable强制转换为AnimationDrawable,我不确定它应该如何工作?