I have some custom class BitmapStorage, not attached to any View or whatever - an utility one.
And I have born_animation.xml file which contains <animation-list> with animation frames:
<animation-list oneshot="true" >
<item drawable="@drawable/frame01" />
<item drawable="@drawable/frame02" />
</animation-list>
I want to load animation from xml file as an AnimationDrawable using Resources class (so it would do all the parsing for me), extract Bitmaps and put them to my custom storage class.
The problem i have:
Resources res = context.getResources();
AnimationDrawable drawable = (AnimationDrawable)res.getDrawable(R.drawable.born_animation);
assertTrue( drawable != null ); <= fails! it's null
WTF? Can someone explain me that? Code compiles fine. All resources are in place.
I tried another way - use ImageView to do the parsing (like described in dev guide)
ImageView view = new ImageView(context);
view.setBackgroundResource(R.drawable.born_animation);
AnimationDrawable drawable = (AnimationDrawable)view.getBackground();
assertTrue( drawable != null ); <= fails! it's null
Results are the same. it returns the null drawable.
Any hinsts would be greatly appreciated, thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…