android download external resources to resolve problems
The following xml in resource-res directory can be automatically compiled referenced by id. However, if the document is downloaded from an external memory to the memory card, how to resolve a drawable class. Please enlighten cattle Here is the background of a button in xml settings
Reply: Reply: android byte converted into drawble, the first copy to the xml data / data / package using byte can be converted into a drawable Reply: Can specific point method under toDrawable Reply: Drawable landlord static method createFromXml () try: public static Drawable createFromXml (Resources r, XmlPullParser parser)
The following is a simple example code, the principle is to be read out to the xml file FileReader object, and then used as an input stream to XmlPullParser object.
XmlPullParser xmlParser = null; File file = new File ("your storage xml file path");
You downloaded files into byte, then by byte then converted into a drawable bitmap
This resource is available for download with a picture of the xml file does not work. Download. 9.png tried to have problems, draw9patch resources, after NinePatchDrawable constructor, smaller corners, Reply:
The following is a simple example code, the principle is to be read out to the xml file FileReader object, and then used as an input stream to XmlPullParser object.
XmlPullParser xmlParser = null; File file = new File ("your storage xml file path");
Drawable.createFromXml method should be used for internal xml, use the drawable id res no problem, copy your code, an exception will be resolved outside of the file, returns null Reply: simple terms, you're reading via binary file, generate the corresponding Bitmap in Android in the OK Reply:
The following is a simple example code, the principle is to be read out to the xml file FileReader object, and then used as an input stream to XmlPullParser object.
XmlPullParser xmlParser = null; File file = new File ("your storage xml file path");
Drawable.createFromXml method should be used for internal xml, use the drawable id res no problem, copy your code, an exception will be resolved outside of the file, returns null
NOT true code returns empty? Reply: xmlParser = Xml.newPullParser (); and Drawable.createFromXml (getResources (), xmlParser); The xmlParser type mismatch fact, I told the source code. Eventually returned drawable is empty.
If I write an analytic category, it seems too difficult. But now reduced customer demand, simply set the color of the lines and so on. It is a new problem encountered is There are two methods GradientDrawable setColors (int [] colors) setOrientation () API Level16 is added, I need to support the 2.3 seems these two methods have to write their own, but this is another issue a new one.
No comments:
Post a Comment