Android Apps (APP) resources are stored in the Res folder at the project level;
The types of resources include values (value), drawable, colors (color), layouts (layout), animations (animation), styles (style), menus (menu), XML files, and raw resources;
Also automatically creates an R-type file containing references to each resource in the project, location:app->build->source->r->debug;
Hello_world, resources as shown:
1. Simple values (value):
Simple values include: strings, colors (color), Dimensions (Dimens), styles (style), string arrays, or integer arrays;
Styles can be inherited, using parent tags, inheriting attributes;
2. Layout (layout)
The layout can be used to define the user interface for any visual component (including activity and fragment), and the filename is the resource identifier;
In activity, the layout uses Setcontentview padding (inflate) to enter the user interface;
Mainactivity, Code:
@Override
protected void onCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main); Populate the user interface with the layout
3. Menus (menu)
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/
After the menu resource is defined in XML, the menu can be filled (inflate) into the application through the inflate method of the Menuinflator service;
The file name is the resource identifier;
Mainactivity, Code:
@Override Public
Boolean oncreateoptionsmenu (Menu menu) {
//inflate the menu; This adds items to the Action bar I F it is present.
Getmenuinflater (). Inflate (R.menu.main, menu); Fill the menu with the user interface return
true;
}
4. drawable
Includes bitmap and ninepatch (PNG image can be stretched), can be used as an icon, should meet the requirements of various sizes;
DPI = Dots-per-inch;
When the remaining resources are used, explain them again.
Author: csdn Blog spike_king