Android projects have their own structural specifications, good compliance with the structure of specifications, can make the development of more than a multiplier. Shows the project structure of the Android project from Android View and Project view, respectively:
The left side of the diagram is Android view and the project view on the right. From the comparison of the two charts, you can find that Android view is more focused on Android development work, and Project view is more focused on the overall structure, although the two views are somewhat different, but the main structure is not different.
Next, mainly through the Android view, describe the use and meaning of the various directories in the Android project, understand the Android view of the user and the meaning of the directory, it is not difficult to find the corresponding directory in Project view.
Project structure:
APP: Android Project code, the usual coding work is done here.
manifests: holds the Androidmanifest.xml file, which is the configuration manifest file in the Android project. Because the model of the Android project is a model of a parent class calling a subclass, the model is simply that the developer inherits the parent class provided by the Android system to implement the app's own subclass, and then the Android system calls the developer's app when it's verified. So this configuration manifest file is very important, only through this file, the Android system will know what is in the developer's application, the developer to declare the application contains the components.
Java: storing Java code in an Android project.
< package name: store Java code.
< package name > (androidtest): store Android test code.
< package name > (test): Store unit test code.
Res: The resource file required to store the Android project.
drawable: storing Picture resource files, in Android system, Google recommends the use of PNG format image resources, in this directory, different screen density of the same name picture resources will be displayed in the folder format.
Layout : Storage of layouts resource files, in this directory, layout resources of the same name with different screen sizes will be displayed in folder format.
Menu : Store the menus resource file, in which the menu resources of different screen sizes will be displayed in the folder format.
mipmap: The image resource file, approximately equivalent to the drawable directory, was introduced in Android 4.2, and Android provides better scaling performance for the image resources in this directory.
Values : holds a value resource, in which a resource of the same type with the same name is displayed in the folder format.
colors.xml: Picture Resource file
dimens.xml: Distance resource file
string.xml: string resource file
style.xml: style resource file
Gradle: Android Project build file that holds Gradle build files and other configuration files.
Multi-terminal support
There are a variety of screen sizes and a wide variety of system versions available in the Android system. Which is what people call fragmentation seriously. Google has actually provided very good technical support for this issue. Like what:
Multi-screen density support
On Android devices, there are two parameters on the screen, one is size, such as 4.7 inch, 5.2 inch, and one is resolution, such as 768 x, 480 x 800. Dimensions represent the physical size of the screen, the resolution represents the number of pixels on the screen, the 3.8-inch screen has a resolution of 768 x 1280 and a 7-inch screen with a resolution of 768 x 1280, which obviously shows a different effect. This difference is due to the screen density, it is simple to understand the screen density as the number of pixels per area.
Taking picture resources as an example, Andorid provides image adaptation support for different screen densities, simply by naming the target resource folder differently. The following is a list of commonly used picture-matching support:
drawable: General Picture Resource Directory
drawable-nodpi: Picture Resource directory that does not need to be scaled
drawable-ldpi: Low screen density image resource
drawable-mdpi: medium screen density picture resource
drawable-hdpi: High screen density picture resources
drawable-xhdpi: ultra-high screen density image resources, on top of it (DRAWABLE-XXHDPI,DRAWABLE-XXXHDPI)
Multi-screen size support
In addition to the perfect support for screen density, the Android system also provides a good taste of the screen size, as an example of a layout file:
Layout : Common Layout File Resources
Layout-land: Widescreen Layout File Resources
layout-small: small screen layout file resource
LAYOUT-W820DP: layout file resource with a screen width of 820DP
Multi-lingual support
Android is the world's most intelligent device with the highest share of the system, multi-lingual support is naturally necessary, in the case of value resource files:
values: Common value resources
values-es.xml: Spanish Locale value resources
values-zh.xml: Simplified Chinese language Environment value resources
Multi-system version support
In order to solve the system fragmentation, the support of multi-system version is naturally necessary, taking the value resource file as an example;
values: Common value resources
Values-v21.xml: Value resources for Android version 5.0 and above
Unit of Measure
Many Android beginners always do not understand the unit of measure in Android, and the following are explanations of some common units of measure:
DP: can be easily understood as screen density, 1dp in high screen density and low screen density of the device performance is different, in order to size can vary with screen density changes, has been maintained with the proportion of the screen, it is generally recommended to use only DP as the unit of measure.
dip: equivalent to DP, just change a vest.
SP: can be simply understood as absolute pixels, the SP does not change with the screen density changes, maintain a fixed size between different devices, for content that want to maintain a fixed size, you can use the SP as a unit of measure, such as on a small screen to use DP on the text, perhaps because the screen is too small, When the text is too small to read after zooming, the use of the SP will keep the text in the same size on different devices.
px: Forget about the most commonly used unit in web development, it's not recommended for Android, so it doesn't explain what it means, and hopefully all Android developers can forget it.
Welcome reprint, reproduced at the same time please respect the copyright, attached to the text link: click here
==============================
For more information, please see my blog: Lin Yanjun's Blog
==============================
"Getting Started" Android Learning notes-project structure and related basics