Android Learning-resource access
1. Static native resources are kept in assets, such as Db,mp3, etc.
2. Other general access by R.
Directory |
Storage Resources |
Description |
/res/animator |
XML for Property animations |
Color switch animation; 3D Rotate Animation |
/res/anim |
XML for a complement animation |
can only support simple zoom, pan, rotate, transparency basic animation, and has certain limitations |
/res/color |
Color |
|
/res/drawable |
XML files that store various bitmap files and drawable Such as: *.png,*.9.png,*.jpg,*.gif Bitmapdrawable Ninepatchdrawable Statelistdrawable Shapedrawable Animationdrawable Drawable various other sub-objects |
Ninepatchdrawable (*.9.png) statelistdrawable changing the background color according to different states Shapedrawable for drawing. animationdrawable Animation |
/res/layout |
Store the interface layout file |
|
/res/menu |
Store Menu |
|
/res/raw |
Store some native resources, such as sound, video, etc. |
InputStream in=getresources (). Openrawresource (R.RAW.AAA); Now it's not recommended to put it here, just put assets. Then through InputStream in=getresources (). Getassets (). Open ("Aaa.txt"); This data can only be read and cannot be written. More importantly, the file size under this directory cannot exceed 1M. |
/res/values |
Customize various resource files Such as: Arrays.xml Strings.xml Colors.xml Demens.xml Styles.xml |
|
/res/xml |
Native XML files can be stored here |
Try{xmlresourceparser XML=getresources (). GETXML (R.XML.BBB); Xml.next (); intEventType =Xml.geteventtype (); while(EventType! =xmlpullparser.end_document) { //Take out the content if the node that arrives at the Mark if(EventType = =xmlpullparser.text) {LOG.V ("Weijj", Encodingutils.getstring (Xml.gettext (). GetBytes (), "Utf-8")); } xml.next (); EventType=Xml.geteventtype (); } } Catch(Exception e) {e.printstacktrace (); } View Code |
drawable Resource Usage
1.BitmapDrawable
drawable drawable=getresources (). getdrawable (R.drawable.ic_launcher); ImageView ImageView1=(ImageView) Findviewbyid (r.id.imageview1); Imageview1.setbackground (drawable);
2.StateListDrawable
Supported states
Property value |
Meaning |
Android:state_active |
Activation status |
Android:state_checkable |
can be checked status |
Android:state_checked |
Checked |
Android:state_enabled |
Available |
Android:state_first |
Start state |
Android:state_focused |
Get Focus Status |
Android:state_last |
End State |
Android:state_middle |
Intermediate state |
Android:state_pressed |
Is installed state |
android:state_selected |
is selected |
Android:state_window_focused |
Whether the window has gained focus |
Android Learning-resource access