Android final exam knowledge summary

Chapter 1: Getting Started with Android Basics

Exercise summary

  1. The Android system adopts a layered architecture, which is divided into 4 layers from high to low, mainly: application layer, application framework layer, core class library, Linux kernel
  2. After the development of the Android project program is completed, it must be packaged into a formal Android installation file before it can be released to the Internet for users to download and use.
  3. The _java__ file is stored in the src directory of the Android project

key knowledge

  1. Application layer: The application layer is a collection of core applications. All applications on the mobile phone belong to this layer, contact program, SMS program
  2. Application framework layer: The application framework layer mainly provides various APIs used in building applications, such as: activity manager, notification manager, content provider
  3. Core class library: The core class library includes the system library and the Android operating environment.
    (1) The system library mainly provides main feature support for the Android system through the c/c++ library
    (2) The Android runtime library mainly provides some core libraries, allowing developers to use the Java language to write Android applications
  4. Linux kernel: Provide underlying drivers for various hardware of Android devices, such as display drivers, audio drivers, Bluetooth drivers, and power management drivers

The assets directory in the Android project mainly stores some file resources, and these files will be packaged into the APK file intact

A more subdivided 5-layer architecture: application layer, application framework layer, core class library, hardware abstraction layer (HAL), Linux kernel hardware
insert image description here
abstraction layer (HAL) provides a standard interface and displays it to a higher-level Java API framework Device hardware capabilities. The HAL consists of several library modules, each of which implements an interface to a specific type of hardware component, such as a camera or a Bluetooth module. When a framework API requires access to device hardware, the Android system loads library modules for that hardware component.

Chapter 2: Android Common Layouts and Controls

knowledge summary

  1. The interface of Android application is constructed by View object and ViewGroup object. ViewGroup inherits from View, and ViewGroup is used as a container to hold other controls in the interface. The
    root element of each interface of an Android application must have one and only one ViewGroup container

Android common layout and features:
Five common layouts in Android: relative layout (RelativeLayout), linear layout (LinearLayout), table layout (TableLayout), frame layout (FrameLayout), constraint layout (ConstraintLayout)

  1. Relative Layout (RelativeLayout): Relative layout is a layout method based on relative position, which can realize the layout by setting the position of components relative to other components or parent containers. The characteristic of relative layout is that more complex layouts can be realized, but the performance will be affected for more nested layouts.
  2. Linear Layout: Linear Layout is a layout method that arranges components in a linear direction, and the horizontal or vertical direction can be set. Linear layout is characterized by simplicity and ease of use, but it may not be flexible enough for complex layouts.
  3. Table Layout (TableLayout): Table layout is a layout method that arranges components in a table form, and rows and columns can be set. The feature of the table layout is that it can achieve a table-like layout, but it may not be flexible enough for irregular layouts.
  4. Frame Layout: Frame Layout is a layout method that arranges components in a hierarchical relationship, and components added later will cover the previous components. The characteristic of frame layout is that it can realize simple cascading layout, but it may not be flexible enough for complex layout.
  5. Constraint Layout (ConstraintLayout): Constraint layout is a layout method that arranges components based on constraint relationships, and the relative position and size between components can be set. The characteristic of constrained layout is that it can realize complex layout with less impact on performance.

Both ListView and RecyclerView are commonly used list controls in Android. Their main differences are as follows:

  • In terms of performance: The performance of RecyclerView is better than that of ListView, because RecyclerView uses the ViewHolder mode, which can better reuse views and reduce memory usage.
  • In terms of layout: ListView only supports linear layout, while RecyclerView supports multiple layouts, including linear layout, grid layout, waterfall flow layout, etc.
  • Animation: RecyclerView supports ItemAnimator, which can easily realize the animation effect of adding, deleting and moving Item.
  • Data source: ListView uses Adapter as data source, while RecyclerView uses Adapter and LayoutManager as data source and layout manager.
  • In terms of caching: RecyclerView supports a flexible caching mechanism and can customize the caching strategy, while the caching mechanism of ListView is relatively fixed.
  • In general, RecyclerView is more flexible and efficient than ListView, while ListView is simpler and easier to use.

There are several ways to implement the Button button click event in Android development:

  1. Declare the onClick attribute in the layout file: declare the onClick attribute of the Button in the layout file, and then implement the corresponding method in the corresponding Activity. When the Button is clicked, the method will be called.
  2. Implement the OnClickListener interface through an anonymous inner class: In the corresponding Activity, pass in an anonymous inner class that implements the OnClickListener interface by setting the setOnClickListener() method of the Button. When the Button is clicked, the onClick() method of the anonymous inner class will be called.
  3. By implementing the OnClickListener interface: In the corresponding Activity, implement the OnClickListener interface, and handle the Button click event in the onClick() method, and then pass in the OnClickListener instance by setting the Button's setOnClickListener() method, when the Button is clicked , the onClick() method will be called.
  4. By inheriting the Button class and rewriting the onClick() method: In the corresponding Activity, create a custom Button class, inherit the Button class and rewrite the onClick() method, handle the Button click event in the onClick() method, and then Use that custom Button class in your layout file.

  • GridLayout is the layout after Android4.0 (API14), which divides the screen area into criss-cross grids with a set of lines without width, and places sub-controls in the grid (cell). Gridlines are represented by gridline subscripts, and a grid with n columns has n+1 grid subscripts, numbered from 0 to n.
  • The sub-control in the Cell can determine its position in the grid through android:layout_column and android:layout_row, and determine how many columns or rows the sub-control occupies by android:layout_columnSpan and android:layout_rowSpan.
  • If the position of the child control is not specified, it will be automatically positioned by the layout properties orientation, rowCount and columnCount of GridLayout.
  • orientation indicates the main sequence of View in the layout; rowCount indicates the number of rows, and columnCount indicates the number of columns

Exercise summary

  1. The property used to assign a theme to the control is style
  2. The attribute used to specify the theme for the Activity is scheme
  3. In Android UI development, if the first TableRow of TableLayout has two controls and the second TableRow has three controls, then this TableLayout has (3) columns
  4. In the Android relative layout, the attribute used to align the control relative to the bottom of the parent control is android:layout_alignParentBottom
  5. In Android UI development, setting the Activity's (android:theme="@android:style/Theme.Dialog") attribute can make the Activity display as a dialog box style
  6. It is android:layout_rowSpan="3" to set a control in GridLayout to occupy 3 rows
  7. android:gravity is used to set the alignment of the internal content of the control, such as text, pictures, etc. Android:layout_gravity is used to set the alignment of the control in the parent container, such as centering, left, and right of the control in the parent container. Simply put, android:gravity is to set the alignment of the internal content of the control, and android:layout_gravity is to set the alignment of the control in the parent container.
  8. In Android UI development, how to set a control to occupy 3 rows in GridLayout android:layout_rowSpan="3"
  9. In Android UI development, if a theme is used in an application, and the View under the application also uses a style, then when there is a conflict between the attributes in the theme and the style, the priority of the theme is lower than that of the style
  10. Toast.makeText(context,text,time) must call the show() method to display the information
  11. In Android UI development, the grid layout is a new layout of [Android4.0], which realizes the interlaced display of controls, can avoid the impact of layout nesting on device performance, and is more conducive to the development of free layout
  12. The EditText control can input text, and the input content can be controlled by the inputType property to be only numbers or letters, etc.
  13. In Android development, if you want the software to support Simplified Chinese and American English, you need to create two values ​​folders in the res directory, named values-zh-rCN and values-en-rUS respectively.
  14. In Android UI development, the number of rows in TableLayout is controlled by the _ TableRow_ object
  15. A theme is a style applied to the entire Activity and Application
  16. In the Android system, _style_is used to define the style of the layout displayed on the interface
  17. The theme and style are the same in code structure, the difference is that the reference of the theme should be referenced in the AndroidManifest.xml file
  18. Android has its own internationalization norms and methods. All text resources in the layout can only be effective if they are referenced by _ android:text="@string/xxx"__
  19. In the manifest file, <application>the andorid:theme attribute in the tag represents the style of the _whole application_theme, and the <activity>style of the _current interface_theme is changed in the tag
  20. In the Android system, __style__ is used to define the style of the control
  21. You can also refer to custom themes in the Activity code, just add the **setTheme()** method in the Activity class onCreate() method
  22. The text in Toast.makeText(context, text, time) is the prompt information

Guess you like

Origin blog.csdn.net/yang2330648064/article/details/131175842