Android and Activity of the four components of the life cycle and five kinds of layout

First, the four components

   Activity: Android is the interaction with the user's window, 

   Service: background service in Activity, there is a complete package of logic functions,

   Content Provider: a third-party application data access solutions provided by Android,  

   BroadCast Receiver: accept a trigger event and related messages do simple processing, unified broadcast model 

 

Two, Activity life cycle

1、 onCreate 

     When you create a call activity, set up in the process, also provides access to any previously saved state in a bundle form

2、 onStart 

        When the user calls to the activity becomes visible on the screen

3, onResume () 

      activity began to call upon user interaction, 

4、onPause 

      When the call is suspended or withdrawn cpu and other resources activity, the method used to save the active state

5 onstop

          At the end of call

6. onRestart

     Restart stack activity

7, the bad story

       The system was completely removed by calling

 

Five kinds of layout

The FrameLayout (frame layout), LinearLayout (linear layout), AbsoluteLayout (absolute layout), RelativeLayout (opposite layout), TableLayout (table layout).

FrameLayout: All things are placed in the upper left corner in turn, overlap, this layout is relatively simple, and can only put a little simple things.

LinearLayout: linear layout, each of which can be divided into LinearLayout horizontal layout and vertical layout. When the vertical layout, each row only one element, a plurality of vertical elements successively downward; horizontal layout, only one row, each element in turn to right.

RelativeLayout: relative layout for the layout will be understood as a reference to a certain element, to locate. The main properties are: a with respect to some elements android: layout_below, android: layout_toLeftOf place relative to the parent element android: layout_alignParentLeft, android: layout_alignParentRigh;


TableLayout: table layout, each of which has a table row TableLayout TableRow, TableRow which can be specifically defined for each element. Each layout has its own appropriate way, these five elements can be nested layout application, make beautiful interface. AbsoluteLayout: absolute layout to specify the elements with X, Y coordinates of the location, this layout is relatively simple, but when the screen is rotated, tend to go wrong, and when multiple elements to calculate too much trouble.

Guess you like

Origin www.cnblogs.com/try-chi/p/12180536.html