Android Study Notes 1.3 Android Application Directory Structure


Zero, learning objectives

1.了解安卓视图
2.熟悉安卓应用目录结构
3.安卓代码控件属性

1. Introduction of new courses

  • In order to better develop Android applications, we should understand the directory structure of Android views and Android applications, and know what files are placed in each commonly used directory and what their uses are.

(1) Android application view

  • Open the Android app we created earlier -HelloWorld
    Insert image description here

1. Find the item in the directory

Insert image description here

  • Click the [OK] button

(2) Android application directory structure

  • By default, Android Studio displays the user's project files in the Android project view, which is organized by module and allows users to quickly access the key source files of the project. All build files of the project are displayed under Gradle Scripts, and each application module contains the following folders: manifests, java, res. It should be noted that the file structure displayed in the Android view is not consistent with the Android project file structure stored on the disk.

1. Project manifest directory - manifests

  • Contains the AndroidManifest.xml file, which describes the basic characteristics of the application and defines each of its components.
    Insert image description here

2. Java source program directory java

  • Store Java source code files and JUnit test code. For example, app/java/<Package Name>/MainActivity, this is the main Activity (the entry point of the Android project). When building and running this project, the system will start an instance of this Activity and load its layout.
    Insert image description here

3. Resource directory res

  • Contains all non-code resources such as XML layouts, UI strings, and bitmap images.
(1) Image resource directory: drawable and mipmap
  • Android application image resource files can be stored in two directories: drawable and mipmap. Both store pictures, and they look no different, but in fact, mipmap will perform some performance optimizations on its scaling when storing pictures, and the pictures will be more beautiful.
    Insert image description here
  • Mipmap is a technology that has been around for a long time, which translates to texture mapping technology. The mipmap technology in Android is mainly to deal with image size scaling. In Android we provide a bitmap image. Due to application needs (such as scaling animation), this bitmap may be reduced in various proportions. In order to improve the speed of reduction and For the quality of pictures, Android uses mipmap technology to generate pictures according to the reduced level and store them in memory in advance, which improves the speed and quality of picture rendering.
  • In the API, Bitmap's public final void setHasMipMap (boolean hasMipMap) method allows the system renderer to try to enable Bitmap's mipmap technology. However, this method can only recommend that the system turns on this function. Whether it is actually turned on or not is still decided by the system.
  • The difference between mipmap and drawable under the res directory is the difference between whether the above setting is turned on or not. The default setHasMipMap for pictures in the mipmap directory is true, and the default setHasMipMap for pictures in the drawable directory is false.
  • Google recommends that you only place the app startup icon in the mipmap directory, and other image resources should still be placed in the drawable directory.
(2) Layout resource directory: layout
  • The resource files corresponding to the boundary classes are stored in the layout directory.
    Insert image description here
(3) Value resource directory: values
  • Contains color resources, string resources, and style resources
    Insert image description here

4. Gradle build script

(1)build.gradle
  • Configure the way the Gradle tool compiles and builds applications. The user will see two files with this name: one for the project (Project: HelloWorld); one for the "Application" module (Module: HelloWorld.app)
    Insert image description here
  • Build file for the project - build.gradle
    Insert image description here
  • Build file for the module - build.gradle
    Insert image description here
(2)gradle.properties
  • Global property settings related to Gradle
    Insert image description here

(3) Android code control control properties

  • The control properties can be set in the layout file, which is the initial property, or the control properties can be set through code when the program is running.

Task: Click on the label to change the text type and color

  • Modify the layout resource file and set idattributes for the label
    Insert image description here
  • Modify the main interface class to implement the function (click the label, modify the text content and color)
    Insert image description here
  • Run the Android app and see the results
    Insert image description here
  • Click on the tab in the middle of the screen
    Insert image description here

2. Computer operation

(1) Modify the layout resource file and set idattributes for the label

Insert image description here

(2) Modify the main interface class to implement functions (click the label and change the color)

Insert image description here

(3) Run the application and view the results

Change text color

Guess you like

Origin blog.csdn.net/qq_41301333/article/details/127783992