How to load AnimationDrawable from xml file

后端 未结 3 512
谎友^
谎友^ 2020-12-06 16:56

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 with

3条回答
  •  无人及你
    2020-12-06 17:11

    This could be used to load resources from the "xml" directory.

    Drawable myDrawable;
    Resources res = getResources();
    try {
       myDrawable = Drawable.createFromXml(res, res.getXml(R.xml.my_drawable));
    } catch (Exception ex) {
       Log.e("Error", "Exception loading drawable"); 
    }
    

提交回复
热议问题