android4 advanced programming (third edition) reading notes

Android4 Advanced Programming (Third Edition) Reading Summary

 

4.1 Basic Design of Android Ui

User Interface (UI)

User Experience (UX)

Human Computer Interaction (HCI)

 

Fragment

Fragment was introduced in Android 3.0 (API level 11), various parts of the user UI. This encapsulation makes Fragments ideal for optimizing UI layouts for different screen sizes and creating reusable UI elements. Each Fragment contains its own UI layout and accepts related input events, but is tightly bound to the Activity that contains them (the Fragment must be embedded in the Activity).

 

4.2 Basics of Android UI

 

 Assign UI to Activity

A new Activity is a blank screen when it is just created, and you can put your own UI on it. To do this, call setContentView and pass in the view instance or layout resource to display.

The setContentView method can accept either a layout resource or an individual view instance. This allows you to define the UI using your favorite techniques of external layout resources, and you can define the UI in code.

 

Layout resource example:

setContentView(R.layout.main);

 Example of a single view:

EditText et2 = new EditText(this);
setContentView(et2);
et2.setText("Hello,android");

 

Using layout resources keeps the presentation layer separate from the application logic, which provides a flexible way to modify the presentation layer without modifying the code. This also makes it possible to specify optimized layouts for different hardware configurations, and even modify these layouts at runtime based on changes in hardware state (eg, changes in screen orientation).

 

4.3 Introduction to Layout

 

4.3.3 Optimize the layout

 

Filling the layout is an expensive process, and each additional nested layout and the View it contains directly affects the performance and responsiveness of the program.

In order for an application to run smoothly and be responsive, it is important to keep the layout as simple as possible to avoid situations where the new layout is completely populated with relatively minor UI changes.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326449889&siteId=291194637