Android Learning-resource access

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.