An explanation of the meaning and purpose of each folder in the project in Android

Source: Internet
Author: User

1.SRC: Store all the *.java source programs.

2.gen: Save path for automatically generated code file for ADT plug-in, R.java will save all resource IDs.

3.assets: Can hold the project some large resource files, such as: pictures, music, fonts and so on.

4.res: Can store all the resource files in the project, for example: Pictures (*.png, *.jpg), text, etc.

5.RES/DRAWABLE-HDPI: Save a high-resolution picture resource, you can use Resources.getdrawable (ID) to get the resource type.

6.RES/DRAWABLE-LDPI: Save a low-resolution picture resource, you can use Resources.getdrawable (ID) to get the resource type.

7.RES/DRAWABLE-MDPI: Save a medium-resolution picture resource, you can use Resources.getdrawable (ID) to get the resource type.

8.res/layout: Store all layout files, mainly for arranging different display components, to read this configuration in the Android program.

9.res/values: To store some resource files for reading text resources, in this folder there are some agreed file names:

. attrs.xml: Custom attribute values: Refer to http://blog.csdn.net/jiangwei0910410003/article/details/17006087 for details Arrays.xml: Define array data;

Defined as follows:

<?XML version= "1.0" encoding= "Utf-8"?><Resources>     <String-arrayname= "MyArray">          <Itemname= "1,35,3">First</Item>           <Itemname= "5,34,0">Second</Item>           <Itemname= "1,30,1">Third</Item>           <Itemname= "2,31,0">Fourth</Item>     </String-array> </Resources>read in code: Resources r = this.getresources ();   string[] ary = R.getstringarray (R.array.myarray); · Colors.xml: Defines the data that represents the color; Dimens.xml: Define a scale that can be used to obtain these resources using resources.getdimension (); Strings.xml: Defines a string that can be obtained using the resources.getstring () or Resources.gettext () method; Styles.xml: Defines the displayed style file;<Resourcesxmlns:android= "Http://schemas.android.com/apk/res/android">         <!--Base application theme, dependent on API level.     This theme are replaced by Appbasetheme from Res/values-vxx/styles.xml on newer devices.  -        <stylename= "Appbasetheme"Parent= "Android:Theme.Light">                  <!--Theme customizations available in newer API levels can go in res/ Values-vxx/styles.xml, while customizations related to Backward-compatibility can         Go here.  -          </style>    <!--application theme. -         <stylename= "Apptheme"Parent= "Appbasetheme">                  <Itemname= "Android:windownotitle">True</Item>         </style>    <!--Global activity Toggle Animation -       <stylename= "MyTheme"Parent= "Apptheme">            <Itemname= "Android:windowanimationstyle">@style/activityanimation</Item>   </style>       <stylename= "Activityanimation">        <!--open activity, set activity to enter display animation -             <Itemname= "Android:activityopenenteranimation">@anim/pubblico_activity_anim_push_right_in</Item>        <!--open activity, set last activity to leave animation -               <Itemname= "Android:activityopenexitanimation">@anim/pubblico_activity_anim_push_left_out</Item>        <!--end activity, set last activity to enter animation -               <Itemname= "Android:activitycloseenteranimation">@anim/pubblico_activity_anim_push_left_out</Item>        <!--end activity, set current activity to leave animation -               <Itemname= "Android:activitycloseexitanimation">@anim/pubblico_activity_anim_push_right_out</Item>        </style></Resources>
View Code

10.res/raw: Custom native files in the same directory, like music, video and other file formats. Store any files that are copied directly to the device. They do not need to be compiled and added to the compressed file generated by your application compilation. To use these resources, you can call Resources.openrawresource (), which is the ID of the resource and can be used, or r.raw. Somefilename, the Resources.getrawresource () method can obtain these resources.

11.res/xml: User-defined XML file, all files are compiled into the application while the program is running, and can be obtained using the Resources.getxml () method when the program is running.

12.res/anim: Used to define an animated object. Stores an XML file that defines a tweened animation (tweened animation) or frame-by-frames animation (Frameby frame animation). (This directory can also hold the XML file that defines the property animations, but it is better to store separately)

13.res/animator: Storing XML files that define the Propertyanimations (Android 3.0 new defined animation framework)

14.res/color/: Storing an XML file that defines a color state list resource (colorstate list Resource)

15.res/drawable/: Storing an XML file that defines a picture Status list resource (colorstate list Resource)

16.res/menu/: Stores an XML file that defines the Application menu resource. How to create a file correctly: New Folder, Name Menu,new other--android--xml, select the menu type, fill in the name, OK. The menu resource file must be placed in the Res/menu directory. The menu resource file must use the <menu> tag as the root node. In addition to the <menu> tags, there are two other tabs for setting menu items and grouping, both <item> and <group>.

Attention:
For the contents of the two files in Res/color and res/drawable, here is a detailed explanation:
First of all, the color folder, in this folder is Color_selector.xml and other files, mainly for the background color of the selector, such as TextView in the TextColor attribute, click Change TextView in the font color, The file Color_selector.xml in this file is defined as follows:
<?XML version= "1.0" encoding= "Utf-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android">    <Itemandroid:state_window_focused= "false"Android:color= "@color/not_pressed" />    <Itemandroid:state_selected= "false"android:state_focused= "false"android:state_pressed= "false"Android:color= "@color/not_pressed"/>    <Itemandroid:state_selected= "true"Android:color= "@color/pressed" />    <Itemandroid:state_focused= "true"Android:color= "@color/pressed" />    <Itemandroid:state_pressed= "true"Android:color= "@color/pressed" /></selector>
View Code
The main attribute is that Android:color references different color values, which are defined in the Values/color.xml file, such as:
<?xml version= "1.0" encoding= "Utf-8"?><resources> <color name= "not_pressed" > #000000 </color > <color name= "pressed" > #ffffff </color></resources>
It can also be found that there is no android:drawable attribute in Color_selector.xml, I do not know what the Android is based on what to judge when there is a android:drawable attribute, when there is Android: of the Color property.
The following is a look at the files in the Res/drawable folder, the file in this folder Drawable_selector.xml, mainly for the use of the background map, button in the Android:background, click to change the background, Definition of drawable_selecor.xml file:
<?XML version= "1.0" encoding= "UTF-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android">    <Itemandroid:state_window_focused= "false"android:drawable= "@drawable/info_collect_btn_normal_bg"/>    <Itemandroid:state_selected= "false"android:state_focused= "false"android:state_pressed= "false"android:drawable= "@drawable/info_collect_btn_normal_bg" />    <!--Non focused states -    <Itemandroid:state_selected= "true"android:drawable= "@drawable/info_collect_btn_pressed_bg" />    <!--Focused states -    <Itemandroid:state_focused= "true"android:drawable= "@drawable/info_collect_btn_pressed_bg" />    <!--Pressed -    <Itemandroid:state_pressed= "true"android:drawable= "@drawable/info_collect_btn_pressed_bg" /></selector>
View Code
Here the INFO_COLLECT_BTN_NORMAL_BG and INFO_COLLECT_BTN_PRESSED_BG are picture resources, placed under the Drawablexx folder.
It is also found that there is no android:color attribute in Drawable_selector.xml, combined with no android:drawable attribute in the color_selector.xml above, Know that Android should be based on the folder to determine, in the Color folder file has the Android:color property, the file under the Drawable folder has the Android:drawable property
It is also important to note that the files referenced by the TextColor and background properties cannot be referenced in a random way, such as textcolor references Drawable_selector.xml,background references Color_ Selector.xml will make an error. So pay attention to the use.
But now there's a question: What if the button now wants to click to turn green and not click to turn red?
The first thing to be sure is to use the properties of the background--that must be referenced with the Drawable_selector.xml file, so in Drawable_selector_.xml will android:drawable= "@ DRAWABLE/INFO_COLLECT_BTN_NORMAL_BG "Change to android:drawable=" @color/not_pressed "can, there may be a misunderstanding is Android: Drawable can only refer to drawable resources, but it turns out that this misunderstanding is superfluous! The principle can be referenced in the attr detailed.

This article was reproduced from: http://blog.csdn.net/jiangwei0910410003/article/details/16985955

An explanation of the meaning and purpose of each folder in the project in Android

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.