About the types of files that are stored in the main folder in Android engineering

Source: Internet
Author: User

The types of files in Android engineering include the following:

A. Jar Package: is to solve the software compatibility problem. If you are developing an application on a low-version Android platform, and the application wants to use a feature that is later, you need to use the support library. Android private libraries and Android 4.2.2, referenced libraries and so on. In fact, the Android private libraries and referenced libraries Two folders are added to the project through the Configure build path way, there is no big difference between the two, the use of the same is no different, I don't know why I have to differentiate. In addition, Android support V4: This package is designed to take care of 1.6 and later, this package is the most widely used, the Eclipse new project, the default comes with. Android Support V7: This package is designed to take care of 2.1 and above, but does not include lower, so if you do not consider 1.6, we can add this package, in addition to note that V7 is to rely on V4 This package, that is, two must be included at the same time. Android Support V13: This package is designed for Android 3.2 and later, generally we are not used, tablet development can be used.
  • The jar inside the JRE system LIBRARY:JRE System Library is a class library (many jar packages) that the Java runtime relies on.
  • The jar inside Java EE 5 Libraries:java EE libraries is the class library (a lot of jar packages) that runs Web engineering dependencies.
  • Referenced libraries: is the class library that the project needs to refer to, here is the reference of the object under Lib directly.
  • Lib: The jar package required to put the various projects of a third party. Adding the jar package into LIB, the system automatically loads the jar into the referenced libraries. what does the order and export under the build path in Eclipse do:
    when building the order and exporting which resources to export, order is to use the Order of class (because it is possible to have a class with the same name), export is to use some of the Lib and project published simultaneously.
    In the order and export entry, the jar package cannot be repeatedly penetrated into the APK, now Android will export the jar into the Android dependencies and Android Private libraries two kinds, The goal is for developers to choose, but in general these two must be scored apk! second, the package of the project
    This package includes the project's class package, as well as the creation of a variety of tool class packages; the various packages of the content you write in the project are centrally placed in the SRC Package folder
    .
    Third, res folder
    includes a variety of resource files,
    1.anim Animation
    <? xml version= "1.0" encoding= "Utf-8" ?> < set xmlns:android= "Http://schemas.android.com/apk/res/android" > <translate Android:fromydelta = "100%" android:duration = " /> " <alpha android:interpolator = "@android: Anim/decelerate_interpolator" android:fromalpha= "0.0" Android:toalpha = "1.0" android:duration = "$" /> </set> 2.color <? xml version= "1.0" encoding= "UTF-8" ?> < selector xmlns:android= "http://schemas.android.com/apk/res/android" > <item android:state_checked = "true" Android:color = "@color/white" /> <item android:state_checked = "false" android:color= "#686868" /> <item android:color = "#686868" /> </selector> 3.drawable (mainly including Chinese and English and hdpi mdpi xhdpi xxhdpi, now the screen is generally large screen, to hdpi more than the main, no resolution differences in the picture directly in the drawable can be)

    (1) drawable-hdpi contains high-resolution images, such as WVGA (480x800), FWVGA (480x854)

    (2) drawable-mdpi contains medium-resolution images, such as HVGA (320x480)

    (3) drawable-ldpi contains low-resolution images, such as QVGA (240x320)


    ldpi:240x320 mdpi:320x480 hdpi:480x800, 480x854 xhdpi: at least 960*720 xxhdpi:1280x720

    Android Adaptive multi-screen support 1, screen-related concepts
    1.1 Resolution
    It means how many pixels are there on the screen.
    1.2 Screen Size
    Refers to the actual physical size of the phone, such as the usual 2.8-inch, 3.2-inch, 3.5-inch, 3.7-inch. 4.65-inch, 5.0-inch, 5.5-inch
    Android divides the screen size into four levels (Small,normal,large,and extra Large).
    1.3 Screen Density
    Pixels per inch
    The phone can have the same resolution, but the screen size can be different,
    Diagonal pixel represents the pixel value (=) of the diagonal, dpi=933/3.7=252
    Android divides the actual screen density into four universal sizes (Low,medium,high,and extra high)
    General screen: LDPI is 120dpi,mdpi is 160dpi,hdpi is 240dpi,xhdpi is 320dpi
    For the screen, the larger the DPI, the higher the fineness of the screen, the more clearly the screen will look
    1.4 Density-independent pixels (density-independent Pixel--dip)
    Dip is a virtual unit of pixels
    The corresponding formula for dip and specific pixel values is dip/pixel=dpi value/160, which is PX = DP * (dpi/160)
    When you define the UI for your app's layout, you should use DP units to ensure that the UI is displayed correctly on different screens.

    The corresponding relationship between cell phone screen classification and pixel density is shown in table 1

    Size distribution of mobile phones (http://developer.android.com/resources/dashboard/screens.html),

    At present, mainly in the resolution of 800*480 and 854*480 mobile phone users mostly
    From the above screen size distribution, in fact, the phone just consider 3-5.5-inch density of 1 and 1.5 of mobile phones

    2. Android multi-screen support mechanism
    Android's support for multi-screen mechanism is used to provide an appropriate way for the current device screen to co-manage and resolve application resources.
    The Android platform supports a range of appropriate resources for the specified size (size-specific), specifying Density (density-specific) that you provide.
    The appropriate resource for the specified size (size-specific) refers to small, normal, large, and XLarge.
    The appropriate resource for specifying density (density-specific) refers to ldpi (low), MDPI (Medium), hdpi (High), and xhdpi (Extra high).
    Android has an automatic matching mechanism to select the corresponding layout and picture resources
    1) Interface layout aspect
    Prepare 5 sets of layouts according to the size of the physical size:
    Layout (Put some common layout XML files, such as the top and bottom layout of the interface, will not change with the screen size, like the WinDOS window title bar),
    Layout-small (the screen size is less than 3 inches or so),
    Layout-normal (screen size is less than 4.5 inches or so),
    Layout-large (between 4 inches-7 inches),
    Layout-xlarge (between 7-10 inches)
    2) Picture Resources
    5 sets of picture resources need to be prepared according to the DPI value:
    Drawable: Primary placement of XML configuration files or images with lower resolution requirements
    DRAWALBE-LDPI: Low-resolution images, such as QVGA (240x320)
    DRAWABLE-MDPI: Medium-resolution picture, such as HVGA (320x480)
    DRAWABLE-HDPI: High-resolution pictures, such as WVGA (480x800), FWVGA (480x854)
    DRAWABLE-XHDPI: At least 960DP x 720DP
    Android has an automatic matching mechanism to select the corresponding layout and picture resources.
    The system will be based on the resolution of the machine to each of these folders to find the corresponding picture.
    In developing the program in order to be compatible with different screens on different platforms, it is recommended that the respective folders store different versions of the images according to requirements.

    3. Androidmanifest.xml Configuration
    Android from 1.6 and higher, Google has added auto-fit functionality to facilitate the porting of various resolution models to developers
    <supports-screens
    Android:largescreens= "true"
    Android:normalscreens= "true"
    Android:smallscreens= "true"
    Android:anydensity= "true"/>
    3.1 Support for multiple screens with different densities
    Android:anydensity=["true" | "False"]
    If android:anydensity= "true"
    The application supports different densities and automatically matches according to the screen resolution.
    If android:anydensity= "false"
    The application supports different densities, and the system automatically scales the image size and coordinates of the image. Explain how the system automatically scales resources.
    For example, if we have the same resource under the Hdpi,mdpi,ldpi folder, then the application will not automatically go to the appropriate folder to find resources, this situation is in high-density, and low-density mobile phones, such as a 240x320 pixel cell phone,
    If you set android:anydensity= "false", the Android system will convert 320 (low density) to 320x480 (medium density), so the app will load the resources in the mdpi file on the small-density phone.
    3.2 Whether to support large screen
    Android:largescreens=["true" | "False"]
    If you declare a large screen that is not supported, and this screen size is larger, the system uses a size of ("normal") and a density of ("medium) display,
    However, a black background will appear.
    3.3 Support for small screens
    Android:smallscreens=["true" | "False"]
    If you declare a small screen that is not supported, and the current screen size is smaller, the system also uses a size of ("normal") and a density of ("medium) display
    This property is not required if the application can be scaled correctly on a small screen (minimum small size or minimum width of 320DP). Otherwise, you should set this property for the minimum screen width identifier
    To match the minimum size required by the application.


    4, Android provides 3 ways to handle screen adaptive
    4.1 Pre-scaled resources (looking for pictures based on size and density)
    1) If you find the appropriate size and density, use these images for a non-scaling display.
    2) If the size cannot be found and the density is found, the image size is considered "medium" and the image is displayed using zoom.
    3) If they do not match, the default picture is used to scale the display. Default image default Standard "medium" (160).
    4.2 Auto-scaled pixel dimensions and coordinates (density compatible)
    1) If the application does not support different densities android:anydensity= "false", the system automatically scales the image size and coordinates of this picture.
    2) for pre-scaled resources, when android:anydensity= "false", it does not take effect.
    3) android:anydensity= "false", only for density compatibility function, size compatibility no effect
    4.3 compatible with larger screens and sizes (size compatible)
    1) for large screens that you do not support, and this screen size is normal, the system uses the size ("normal") and density ("medium") to display.
    2.) for large screens that you do not support in the declaration, and this screen size is larger, the system also uses dimensions ("normal") and density ("medium") to display,
    However, a black background will appear.

    5, Android system automatic adaptation skills
    The Android system uses the following two ways to automate the application:
    1) When defining the length in the layout file, it is best to use wrap_content,fill_parent, or DP, to ensure that the screen is displayed with the appropriate size
    2) for different screen density of mobile phones, provide different bitmap resources, can make the interface clear and non-scaling.
    For bitmap resources, automatic scaling sometimes causes the zoomed-out image to become blurred, which requires applications to provide different resources for different screen density configurations: high-definition images for dense screens, etc.
    3) do not use Absolutelayout
    4) Use Dip for pixel units, use SP for text units

    6. Get screen pixel, screen density in code
    Displaymetrics metric = new Displaymetrics ();
    Getwindowmanager (). Getdefaultdisplay (). Getmetrics (Metric);
    int width = metric.widthpixels; Screen width (pixels)
    int height = metric.heightpixels; Screen height (pixels)
    float density = metric.density; Screen Density (0.75/1.0/1.5)
    int densitydpi = metric.densitydpi; Screen density dpi (120/160/240)

    7, general multi-resolution processing method and its shortcomings
    7.1 Image Zoom
    Based on the accuracy of the current screen, the platform automatically loads any non-scaled, dimensioned and precision pictures. If the picture does not match, the platform loads the default resources and, after zooming in or out, satisfies the current interface's display requirements. For example, for a high-precision screen, the platform loads high-precision resources (such as bitmap resources in drawable-hdpi in helloandroid), and if not, the platform scales medium precision resources to high precision, resulting in unclear picture display.
    7.2 Automatically define pixel dimensions and locations
    If the program does not support multiple precision screens, the platform automatically defines the pixel absolute position and size values, so that the element can show the same size as the accuracy of 160 on the screen. For example, to let the WVGA high-precision screen and the traditional HVGA screen display the same size picture, when the program is not supported, the system will lie to the screen resolution of 320x480, after the (10,10) to (100,100) in the area of the drawing is completed, the system will enlarge the graph to (15, 15) to the (150,150) screen display area.
    7.3 Compatible with larger screen sizes
    When the current screen exceeds the upper limit of the screen supported by the program, the Supportsscreens element is defined so that the platform displays a black background image when it exceeds the displayed baseline. For example, WVGA in the precision screen, such as the program does not support such a large screen, the system will be lied to be a 320x480, the extra display area will be filled with black.
    7.4 Dynamic drawing of images with OpenGL
    The Android bottom layer provides OpenGL interfaces and methods to dynamically draw pictures, but this is a great challenge for developers unfamiliar with computer graphics. General development game, using OpenGL mode.
    More than 7.5 apk files
    Symbian and the traditional j2me in this way, for an application to provide multiple resolution versions, users according to their own needs to download and install the appropriate executable files. It's a good idea to develop apps separately for each screen, but Google market's support for multiple resolution versions of an application is not perfect at the moment, and developers need to use an APK file to accommodate multiple resolutions whenever possible.
    Iv. Other folders
    materials (other files that need to be used in the project can be set up on their own, but this folder will not be packaged into the project, just as other auxiliary files for development convenience,
    Android In addition to provide/res directory storage resource files, in the/assets directory will also provide storage resources files, put some smaller files, the program as a local file use, because he is used as a local file of the program, so the file is not too large, otherwise the load time is too long Pour to ANR error. For example, some fixed data, such as national provinces and cities, gender, etc. can exist in the asset as a resource use. The most difference with other directories is that the files under this folder do not generate IDs, so the resource files under the assets directory need to provide a path, and we can access the files through the Assetmanager class.
    1. public void Deepfile (Context ctxdealfile, String path) {
    2. try {
    3. String str[] = ctxdealfile.getassets (). List (path);
    4. if (Str.length > 0) {//If it is a directory
    5. File File = new file ("/data/" + path);
    6. File.mkdirs ();

About the types of files that are stored in the main folder in Android engineering

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.